簡體   English   中英

使用Azure Management C#API創建資源組

[英]Create Resource Group with Azure Management C# API

有沒有辦法使用Azure Management C#API創建資源組?

基本上這個REST API調用: https//msdn.microsoft.com/en-us/library/azure/dn790525.aspx

我找到了一種使用client.AffinityGroups.Create創建Affinity Group的方法,但這是我發現的最接近的東西。

我發現API調用隱藏在一個只在預覽模式下的庫中。 它位於以下NuGet包中,在Visual Studio中啟用include prerelease以在NuGet客戶端中找到它。

https://www.nuget.org/packages/Microsoft.Azure.Management.Resources/

然后創建一個我可以使用的資源組

var credentials = new TokenCloudCredentials("", "");
var client = new Microsoft.Azure.Management.Resources.ResourceManagementClient(credentials);            
var result = c.ResourceGroups.CreateOrUpdateAsync("MyResourceGroup", new Microsoft.Azure.Management.Resources.Models.ResourceGroup("West US"), new System.Threading.CancellationToken()).Result;

還有另一個堆棧溢出帖子解釋了如何進行身份驗證: 如何獲取Azure ResourceManagementClient對象的標記

以下博客文章更詳細地介紹了如何設置身份驗證部分所需的TokenCloudCredentials,但僅適用於命令行應用程序: http ://www.bradygaster.com/post/using-windows-azure-active-directory- 到驗證,在管理的庫

如果您想使用命令行應用程序之外的其他內容,則以下內容可用於身份驗證: http//www.dushyantgill.com/blog/2015/05/23/developers-guide-to-auth-with-azure-resource -manager-API /

轉到https://resources.azure.com - ARMExplorer顯示REST和PowerShell命令以創建資源組。 所有API都基於REST。 在C#中,發送WebClient請求。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM