如何使用Azure SDK创建嵌套Azure资源

时间:2018-01-05 05:26:27

标签: azure azure-storage azure-sdk-.net azure-batch azure-sdk

使用ARM模板,我们可以在批处理帐户下定义存储帐户。但是我们如何使用.NET SDK来做到这一点?目前,我可以将BatchAccount和StorageAccount创建为单独的资源,但是如果StorageAccount应该出现在BatchAccount I.e下,该怎么办?在" SETTINGS" BatchAccount的TAB

1 个答案:

答案 0 :(得分:0)

下面的代码适用于我。

 //Getting StorageAccount to bind
var storageAccount = await storageManagementClient.StorageAccounts.GetPropertiesAsync("testresourcegroup", "teststorageaccount");

//Creating binding properties
       AutoStorageBaseProperties baseProperties = new AutoStorageBaseProperties { StorageAccountId = storageAccount.Id };

       //Creating update parametrs for Batch Account
       BatchAccountUpdateParameters updateParameters = new BatchAccountUpdateParameters { AutoStorage = baseProperties };

       //Updatting the BatchAccount to bind with chosen StorageAccount
       var response = await batchManagementClient.BatchAccount.UpdateAsync("testresourcegroup", "testbatchaccount", updateParameters);