Azure / Azure/azure-libraries-for-java
[BUG] Cannot access CDN profiles when using `AppServiceMSICredentials`+`withDefaultSubscription`.
- Lingua principale
- Java
- Stelle
- 97
- Fork
- 102
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
**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
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start by reproducing the Java snippet using Azure.authenticate(new AppServiceMSICredentials(AzureEnvironment.AZURE)).withDefaultSubscription(), then call azure.cdnProfiles().getByResourceGroup. Trace how the default subscription reaches the CDN client and inspect the ProfilesInner stack location shown in the report. Done means the CDN lookup no longer fails because subscriptionId is null.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- azure, java
- Ambito
- api, cloud
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100