Azure / azure-rest-api-specs

The source for REST API specifications for Microsoft Azure.
MIT License
2.69k stars 5.12k forks source link

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

Open jiasli opened 4 years ago

jiasli commented 4 years ago

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. 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:

  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.

yonzhan commented 4 years ago

Azure Stack Resources

ghost commented 4 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @sijuman.

bganapa commented 4 years ago

@jiasli I think we should be able unblock with the API Profile setting for azurestack consuming a older version. Please let me know if this issue is blocking you

bganapa commented 4 years ago

Actually the api version 2019-06-01 is not supported and azurestack should return Not Supported error for the call. It is not happening right now. We will fix it

jiasli commented 4 years ago

Thanks @bganapa, using an old API does solve the issue. But you are right:

Azure Stack should return Not Supported error for the call.

bganapa commented 4 years ago

@jiasli WE have ainternal trackign item for the Not Supported return issue. Can we close this issue?

jiasli commented 4 years ago

I noticed this issue is still not fixed yet. When will this be deployed?

ghost commented 3 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @sijuman, @sarathys, @bganapa, @rakku-ms.

Issue Details
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.
Author: jiasli
Assignees: bganapa
Labels: `Azure Stack`, `Service Attention`
Milestone: -