簡體   English   中英

從 Azure Web 應用托管服務標識創建資源組

[英]Creating resource groups from Azure Web App Managed Service Identity

我正在嘗試使用 MS Bot 框架構建一個機器人,並且該機器人作為 Azure Web 應用程序托管。 我添加了使用Microsoft.Azure.Management.Fluent API 創建資源組的代碼

AzureCredentialsFactory f = new AzureCredentialsFactory();
var msi = new MSILoginInformation(MSIResourceType.AppService);

var msiCred = f.FromMSI(msi, AzureEnvironment.AzureGlobalCloud);

var azureAuth = Azure.Configure()
                 .WithLogLevel(HttpLoggingDelegatingHandler.Level.BodyAndHeaders)
                 .Authenticate(msiCred);

var azure = azureAuth.WithSubscription(subscription);

var resourceGroup = azure.ResourceGroups.Define(rg)
                                    .WithRegion(Region.EuropeWest)
                                    .Create();

此代碼利用了 Web 應用程序的托管服務標識。 我已將此 Web 應用程序設為 Azure 訂閱的“所有者”。

當我執行此代碼時,我不斷收到此異常

例外:已從錯誤的受眾或資源“ https://management.core.windows.net ”獲取訪問令牌。 它應該完全一致(包括斜杠)與允許觀眾“的一個https://management.core.windows.net/ ”,“ https://management.azure.com/ ”。

我從不手動設置受眾或資源,也沒有看到有關如何執行此操作的任何選項。

當我更改代碼以使用我自己創建的服務主體時,效果很好

ServicePrincipalLoginInformation loginInfo = new ServicePrincipalLoginInformation() 
{ 
    ClientId = _clientId, 
    ClientSecret = _clientSecret 
}; 

var credentials = new AzureCredentials(loginInfo, _tenantId, AzureEnvironment.AzureGlobalCloud);
var azureAuth = Azure.Configure()
             .WithLogLevel(HttpLoggingDelegatingHandler.Level.BodyAndHeaders)
             .Authenticate(credentials);

如何設置此受眾或資源或我做錯了什么?

如何設置此受眾或資源或我做錯了什么?

我也可以在我這邊重現這個問題。 看來是SDK的問題。 您可以將其報告給Azure SDK github 問題

更新:

根據issue-4090 ,已經在 1.7 版本修復,如果發布可以再次測試。

暫無
暫無

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

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