Azure / Azure/azure-libraries-for-java

[BUG] Cannot access CDN profiles when using `AppServiceMSICredentials`+`withDefaultSubscription`.

オープン
#775 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る
customer-reported Mgmt needs-more-info Network - CDN
主要言語
Java
スター
97
フォーク
102
PR マージ指標
30日以内にマージされた PR はありません

説明

**Describe the bug**
When using `AppServiceMSICrednetials` for authentication and `withDefaultSubscription`, the default subscription ID does not appear to propagate to CDN API client.

***Exception or Stack Trace***
```
Exception: IllegalArgumentException: Parameter this.client.subscriptionId() is required and cannot be null.
Stack: java.lang.IllegalArgumentException: Parameter this.client.subscriptionId() is required and cannot be null.
at com.microsoft.azure.management.cdn.implementation.ProfilesInner.getByResourceGroupWithServiceResponseAsync(ProfilesInner.java:415)
at com.microsoft.azure.management.cdn.implementation.ProfilesInner.getByResourceGroupAsync(ProfilesInner.java:391)
at com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.TopLevelModifiableResourcesImpl.getInnerAsync(TopLevelModifiableResourcesImpl.java:64)
at com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl.getByResourceGroupAsync(GroupableResourcesImpl.java:115)
at com.microsoft.azure.management.resources.fluentcore.arm.collection.implementation.GroupableResourcesImpl.getByResourceGroup(GroupableResourcesImpl.java:110)
```

**To Reproduce**
Deploy the following code in an Azure Function in Java:

***Code Snippet***
```java
import com.microsoft.azure.management.Azure;
import com.microsoft.azure.management.cdn.CdnProfile;
//...
//Inside the function body:
Azure azure = Azure.authenticate(new AppServiceMSICredentials(AzureEnvironment.AZURE)).withDefaultSubscription();
CdnProfile cdnProfile = azure.cdnProfiles().getByResourceGroup(cdnResourceGroup, cdnProfileId);

//...
```

**Expected behavior**
The code should work, as the account does have a default subscription as verified via `az account list -otable`.

**Setup (please complete the following information):**
Client library 1.0.22.

Setup for MSI, CDN, and RBAC via PowerShell:

```powershell
Set-AzWebApp -AssignIdentity $true -Name $appName -ResourceGroupName $resourceGroupName

$cdnProfile = New-AzCdnProfile -ProfileName uploadCdnProfile -ResourceGroupName $resourceGroupName -Sku Standard_Verizon -Location $appRegion
$cdnEndpoint = New-AzCdnEndpoint -EndpointName $uploadCdnProfile -CdnProfile $cdnProfile -OriginName $storageAccountName -OriginHostName $cdnHost
New-AzRoleAssignment -ResourceName $cdnProfile.Name -ResourceGroupName $resourceGroupName -RoleDefinitionName Contributor -ApplicationId $appServicePrincipal.ApplicationId -ResourceType Microsoft.Cdn/profiles

```

**Information Checklist**
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- [x] Bug Description Added
- [x] Repro Steps Added
- [x] Setup information Added

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、Azure.authenticate(new AppServiceMSICredentials(AzureEnvironment.AZURE)).withDefaultSubscription() を使用して Java スニペットを再現し、次に azure.cdnProfiles().getByResourceGroup を呼び出します。既定のサブスクリプションが CDN クライアントにどのように到達するかを追跡し、レポートに示されている ProfilesInner のスタック位置を調べます。subscriptionId が null であることが原因で CDN ルックアップが失敗しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
azure, java
領域
api, cloud
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。