.NET 用 Azure Resource Manager ライブラリ
概要
Azure Resource Manager を使用すると、ソリューション内の複数のリソースを 1 つのグループとして作業できます。 Resource Manager について詳しくは、「Azure Resource Manager の概要」をご覧ください。
管理ライブラリ
.NET 用 Azure Resource Manager ライブラリを使うと、リソースおよびリソース グループの作成、更新、削除、一覧表示を行うことができます。
NuGet パッケージを Visual Studio パッケージ マネージャー コンソールから直接インストールするか、.NET Core CLI を使ってインストールします。
Visual Studio パッケージ マネージャー
Install-Package Azure.ResourceManager
dotnet add package Azure.ResourceManager
例
この例では、新しいリソース グループを作成します。
// First, initialize the ArmClient and get the default subscription
ArmClient client = new ArmClient(new DefaultAzureCredential());
// Now we get a ResourceGroupResource collection for that subscription
SubscriptionResource subscription = await client.GetDefaultSubscriptionAsync();
ResourceGroupCollection resourceGroups = subscription.GetResourceGroups();
// With the collection, we can create a new resource group with an specific name
string resourceGroupName = "myRgName";
AzureLocation location = AzureLocation.WestUS2;
ResourceGroupData resourceGroupData = new ResourceGroupData(location);
ArmOperation<ResourceGroupResource> operation = await resourceGroups.CreateOrUpdateAsync(WaitUntil.Completed, resourceGroupName, resourceGroupData);
ResourceGroupResource resourceGroup = operation.Value;
サンプル
GitHub で Microsoft と共同作業する
このコンテンツのソースは GitHub にあります。そこで、issue や pull request を作成および確認することもできます。 詳細については、共同作成者ガイドを参照してください。
Azure SDK for .NET