【发布时间】:2018-12-05 22:49:36
【问题描述】:
我已经通过 c# 中的 Fluent API 类在 Azure 门户上创建了虚拟机。 我的 C# 代码是:
public JsonResult createVM()
{
try
{
IAzure azure = Authenticate(subscriptionId);
azure.VirtualMachines.Define(vmName)
.WithRegion(location)
.WithExistingResourceGroup(ResourceGroupName)
.WithExistingPrimaryNetworkInterface(networkInterface)
.WithSpecializedOSDisk(managedDisk, operatingSystem)
.WithSize(vmSize)
.Create();
//Here i want complete response from above code..if success.
return Json(string.Empty);
}
catch (CloudException ex)
{
Response.Write(ex.Response.Content);
return Json(string.Empty);
}
}
如果执行失败,我会在 catch 块中得到响应。 但如果执行成功,我们需要响应。
【问题讨论】:
标签: c# azure virtual-machine azure-sdk-.net azure-management-api