Azure / Azure/azure-libraries-for-java

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

Offen
#775 6 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
customer-reported Mgmt needs-more-info Network - CDN
Vorherrschende Sprache
Java
Sterne
97
Forks
102
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

**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

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne damit, das Java-Snippet mit Azure.authenticate(new AppServiceMSICredentials(AzureEnvironment.AZURE)).withDefaultSubscription() nachzustellen, und rufe anschließend azure.cdnProfiles().getByResourceGroup auf. Verfolge, wie das Standardabonnement den CDN-Client erreicht, und untersuche die im Bericht angegebene Stack-Position von ProfilesInner. Als erledigt gilt die Aufgabe, wenn die CDN-Suche nicht mehr fehlschlägt, weil subscriptionId null ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, java
Bereich
api, cloud
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.