Azure / azure-sdk-for-go

This repository is for active development of the Azure SDK for Go. For consumers of the SDK we recommend visiting our public developer docs at:
https://docs.microsoft.com/azure/developer/go/
MIT License
1.59k stars 821 forks source link

AAD Domain Service create/update fails with Request_InvalidDataContractVersion #3924

Closed tiwood closed 5 years ago

tiwood commented 5 years ago

Bug Report

I'm trying to create a Azure AD Domain Service resource, but the API returns Request_InvalidDataContractVersion while using the azure-sdk-for-go@v24.1.0

/subscriptions/{subscriptionid}/resourceGroups/{resourceGroup}/providers/Microsoft.AAD/domainServices/{domainServiceName}?api-version=2017-06-01

{
    "odata.error": {
        "code": "Request_InvalidDataContractVersion",
        "message": {
            "lang": "en",
            "value": "The specified api-version is invalid. The value must exactly match a supported version."
        }
    }
}
jhendrixMSFT commented 5 years ago

In what region are you making this API call?

tiwood commented 5 years ago

West Europe

jhendrixMSFT commented 5 years ago

@jihochang can you please take a look?

tiwood commented 5 years ago

Hi @jhendrixMSFT, @jihochang - any updates on the matter? Can I provide more details?

jhendrixMSFT commented 5 years ago

@tiwood I'm following up with the service team about this. By change do you have a sample JSON request body? You can use the built-in logging facility to generate this, see here for info on how to do this.

tiwood commented 5 years ago

Hi @jhendrixMSFT, I've captured the request:

PUT /subscriptions/92807d76-6b48-4482-9e6d-bf034fede571/resourceGroups/adds_test/providers/Microsoft.AAD/domainServices/AlexanderBeissneroutlook.onmicrosoft.com?api-version=2017-06-01 HTTP/1.1

{
    "properties": {
        "tenantId": "63f2c9fc-542b-4758-806f-3cc9c6c78fea",
        "domainName": "AlexanderBeissneroutlook.onmicrosoft.com",
        "vnetSiteId": "/subscriptions/c356d2d3-7531-47ce-83bc-8938d820f8b1/resourceGroups/adds_test/providers/Microsoft.Network/virtualNetworks/virtualNetwork1",
        "subnetId": "/subscriptions/c356d2d3-7531-47ce-83bc-8938d820f8b1/resourceGroups/adds_test/providers/Microsoft.Network/virtualNetworks/virtualNetwork1/subnets/domainservices"
    }
}

and this is the response:

{
    "odata.error": {
        "code": "Request_InvalidDataContractVersion",
        "message": {
            "lang": "en",
            "value": "The specified api-version is invalid. The value must exactly match a supported version."
        }
    }
}

To add to this, I'm currently using Terraform to run call the Azure GO SDK.

jhendrixMSFT commented 5 years ago

@tiwood thanks I've passed this on to the service team for investigation.

jihochang commented 5 years ago

Hello @tiwood and @jhendrixMSFT,

I am not sure why the error is related to api-version. The api-version 2017-06-01 looks correct.

As for the property inputs, you should not provide the VnetSiteId and tenantId. These are fields populated by the backend service. The tenant id is derived from the caller context and the vnetSiteId is used for classic virtual networks in the past. Please try removing these and only pass the domainName and subnetId.

I am not sure if its in the header, but the top level resource definitions also should have a location field.

tiwood commented 5 years ago

Hi @jihochang,

Thank you for your response. I've tried the following, but unfortunately it produced the same error message:

{
    "location": "westeurope",
    "properties": {
        "domainName": "AlexanderBeissneroutlook.onmicrosoft.com",
        "subnetId": "/subscriptions/c356d2d3-7531-47ce-83bc-8938d820f8b1/resourceGroups/adds_test/providers/Microsoft.Network/virtualNetworks/virtualNetwork1/subnets/domainservices"
    }
}
jihochang commented 5 years ago

@jhendrixMSFT - The api-version being passed is correct and supported on the Domain Services resource provider. Could this be an issue on the SDK GO version or inputs?

jhendrixMSFT commented 5 years ago

@jihochang The response is coming from the REST endpoint. What are the next steps here, are there back-end logs for this request you can view?

jhendrixMSFT commented 5 years ago

@tiwood could you please share the full URL from your PUT request?

jhendrixMSFT commented 5 years ago

@tiwood also if you have a request ID (the x-ms-request-id header value) that would be helpful for the service team to find the request on the back-end.

tiwood commented 5 years ago

@jhendrixMSFT here are the requested details:

RAW Request:

PUT /subscriptions/92807d76-6b48-4482-9e6d-bf034fede571/resourceGroups/adds_test/providers/Microsoft.AAD/domainServices/AlexanderBeissneroutlook.onmicrosoft.com?api-version=2017-06-01 HTTP/1.1
Host: graph.windows.net
User-Agent: Go/go1.11.5 (amd64-darwin) go-autorest/v11.2.8 Azure-SDK-For-Go/v24.1.0 aad/2017-06-01 Terraform/0.11.9 terraform-provider-azuread/dev
Content-Length: 319
Authorization: Bearer <snip>
Content-Type: application/json; charset=utf-8
Accept-Encoding: gzip

{"location":"westeurope","name":"AlexanderBeissneroutlook.onmicrosoft.com","properties":{"domainName":"AlexanderBeissneroutlook.onmicrosoft.com","subnetId":"/subscriptions/c356d2d3-7531-47ce-83bc-8938d820f8b1/resourceGroups/adds_test/providers/Microsoft.Network/virtualNetworks/virtualNetwork1/subnets/domainservices"}}

RAW Response:

HTTP/1.1 400 Bad Request
Cache-Control: private
Content-Type: application/json; odata=verbose
Server: Microsoft-IIS/10.0
ocp-aad-diagnostics-server-name: +yD+FhcBb8tUXvrt20+iv/3Zym7XJiXO5AZ6j8c3jyg=
request-id: 6057ed16-a22f-430a-8136-31511e8d27e9
client-request-id: 6a57008d-74cc-44d1-b087-a1f084974a4c
Strict-Transport-Security: max-age=31536000; includeSubDomains
Access-Control-Allow-Origin: *
X-Powered-By: ASP.NET
Duration: 99072
Date: Tue, 05 Feb 2019 16:38:26 GMT
Content-Length: 183
Connection: keep-alive

{"odata.error":{"code":"Request_InvalidDataContractVersion","message":{"lang":"en","value":"The specified api-version is invalid. The value must exactly match a supported version."}}}

Thanks again for looking into it.

jhendrixMSFT commented 5 years ago

@tiwood Is the host really graph.windows.net? That doesn't seem right. If you look at the client for aad it should be management.azure.com. Do you have repro code to share?

tiwood commented 5 years ago

@jhendrixMSFT, thank you for assisting me with my issue. It turns out that I made a mistake in the initialization, which resulted in the wrong host uri. As soon as I used management.azure.com the creation was successful.

Sorry for the noise

jhendrixMSFT commented 5 years ago

No worries I'm following up with the service team to see if the error message can be improved as it wasn't clear what the underlying problem actually was.