Azure / Azure/azure-libraries-for-java
[BUG] Cannot access CDN profiles when using `AppServiceMSICredentials`+`withDefaultSubscription`.
- Langage dominant
- Java
- Étoiles
- 97
- Forks
- 102
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
**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
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Commencez par reproduire l’extrait Java en utilisant Azure.authenticate(new AppServiceMSICredentials(AzureEnvironment.AZURE)).withDefaultSubscription(), puis appelez azure.cdnProfiles().getByResourceGroup. Suivez la manière dont l’abonnement par défaut parvient au client CDN et examinez l’emplacement dans la pile de ProfilesInner indiqué dans le rapport. Le travail est terminé lorsque la recherche CDN n’échoue plus parce que subscriptionId est null.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- azure, java
- Domaine
- api, cloud
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 35/100