Azure / Azure/azure-rest-api-specs

[Resources] Response from Azure Stack doesn't comply with the spec subscriptions.json

Open
#9,567 8 comments 0 reactions 0 assignees View on GitHub
Azure Stack Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
2d 22h
Merged PRs (30d)
444

Description

When using `2019-06-01` with Azure Stack to get subscriptions (in this case `management.redmond.azurestack.corp.microsoft.com`), the response doesn't comply with the REST spec [`subscriptions.json`](https://github.com/Azure/azure-rest-api-specs/blob/master/specification/resources/resource-manager/Microsoft.Resources/stable/2019-06-01/subscriptions.json). For example, `authorizationSource` and `managedByTenants` are missing from the response.

https://github.com/Azure/azure-rest-api-specs/blob/76b6bd1989a8248987219b840f525b02e07807dc/specification/resources/resource-manager/Microsoft.Resources/stable/2019-06-01/subscriptions.json#L271-L277

```
> az cloud register -n redmond --endpoint-resource-manager "https://management.redmond.azurestack.corp.microsoft.com/"
> az cloud set -n redmond
> az login --debug

msrest.http_logger : Request URL: 'https://management.redmond.azurestack.corp.microsoft.com/subscriptions?api-version=2019-06-01'
msrest.http_logger : Request method: 'GET'

msrest.http_logger : Response status: 200
msrest.http_logger : Response content:
msrest.http_logger :
{
"value": [
{
"offerId": "/delegatedProviders/default/offers/full-offer",
"id": "/subscriptions/c9b8dfff-aff0-49b5-93bd-a1581f1896a0",
"subscriptionId": "c9b8dfff-aff0-49b5-93bd-a1581f1896a0",
"tenantId": "81cfafcd-8b9a-4419-9c85-823b54076b55",
"displayName": "azclidevtools",
"state": "Enabled",
"subscriptionPolicies": {
"locationPlacementId": "AzureStack"
}
}
]
}
```

This causes failure in Azure CLI when [retrieving `managed_by_tenants`](https://github.com/Azure/azure-cli/blob/80c7bc79d416007d86848650b149d5fa24783c19/src/azure-cli-core/azure/cli/core/_profile.py#L275-L276):

```
File "C:\Users\jiasli\AppData\Local\Programs\Python\Python38\lib\site-packages\azure\cli\core\_profile.py", line 276, in _normalize_properties
subscription_dict[_MANAGED_BY_TENANTS] = [{_TENANT_ID: t.tenant_id} for t in s.managed_by_tenants]
TypeError: 'NoneType' object is not iterable
```

The response of the public `AzureCloud` is:

```
> az cloud set -n AzureCloud
> az login --debug

msrest.http_logger : Request URL: 'https://management.azure.com/subscriptions?api-version=2019-06-01'
msrest.http_logger : Request method: 'GET'

msrest.http_logger : Response status: 200
msrest.http_logger : Response content:
msrest.http_logger :
{
"value": [
{
"id": "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590",
"authorizationSource": "RoleBased",
"managedByTenants": [
{
"tenantId": "2f4a9838-26b7-47ee-be60-ccc1fdec5953"
}
],
"subscriptionId": "0b1f6471-1bf0-4dda-aec3-cb9272f09590",
"tenantId": "54826b22-38d6-4fb2-bad9-b7b93a3e9c5a",
"displayName": "AzureSDKTest",
"state": "Enabled",
"subscriptionPolicies": {
"locationPlacementId": "Internal_2014-09-01",
"quotaId": "Internal_2014-09-01",
"spendingLimit": "Off"
}
}
],
"count": {
"type": "Total",
"value": 1
}
}
```

If `2019-06-01` is not supported, the service should return "unsupported API version" instead a wrong response which doesn't comply with the spec.

Contributor guide

Open the contributing guide

Research direction

Read specification/resources/resource-manager/Microsoft.Resources/stable/2019-06-01/subscriptions.json around lines 271-277 and compare its requirements with the captured Azure Stack response. Then inspect azure-cli-core/azure/cli/core/_profile.py around lines 275-276 to understand the reported failure; done means the service complies with the specification or explicitly rejects the unsupported API version.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.