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

问题描述 投票:-1回答:1

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

azure azure-storage azure-sdk-.net azure-batch azure-sdk
1个回答
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);
© www.soinside.com 2019 - 2024. All rights reserved.