【发布时间】:2017-05-19 21:06:21
【问题描述】:
我正在使用 Azure 管理库(特别是 fluent)向他们的 api 创建 Web 请求,以获取我订阅下的数据库列表。我能够使用 fluent 获取 sqlserver 的实例,但无法获取特定服务器下所有数据库的列表。 定义和删除工作正常,它只是 list() 函数。
我已经尝试将它用于 sqlserver.firewallrules,但列表功能也无法正常工作。
下面是一些代码: 日志在某些时候只是暂停然后写“已退出,代码为 0”
public async Task<List<String>> getSqlDatabaseList()
{
System.Diagnostics.Debug.WriteLine("Starting to get database list");
List<string> dbNameList = new List<string>();
//the var azure is defined earlier in the project and is authenticated.
var sqlServer = await azure.SqlServers.GetByResourceGroupAsync("<resource group name>", "<server Name>");
//The code below successfully writes the server name
System.Diagnostics.Debug.WriteLine(sqlServer.Name);
//The code below here is where everyting stop and "has exited with code 0" happens after a few seconds of delay
var dbList = sqlServer.Databases.List();
//Never reaches this line
System.Diagnostics.Debug.WriteLine("This line never is written");
foreach (ISqlDatabase db in dbList)
{
dbNameList.Add(db.Name);
}
return dbNameList;
}
说明: 我正在使用 ASP.NET MVC 这是我的控制器方法访问类方法的方式。资源管理器是实现getSQlDatabaseList()的类名;
// GET: Home
public async Task<ActionResult> Index()
{
ResourceManager rm = new ResourceManager();
List<string> test = await rm.getSqlDatabaseList();
//Never Gets to this line of code and never calls the for each or anything after
foreach (var item in test)
{
System.Diagnostics.Debug.WriteLine(item);
}
System.Diagnostics.Debug.WriteLine("Is past for each");
//AzureManager azm = await AzureManager.createAzureManager();
//await azm.getResourceGroupList();
return View(new UserLogin());
}
【问题讨论】:
-
更多说明:这是使用 Asp.net MVC 的 Web 应用程序的一部分。
标签: c# asp.net database asynchronous azure-sdk-.net