"The resource type 'locks' could not be found in the namespace 'Microsoft.Authorization' for api version '2020-05-01'

Sunil 1 Reputation point
2022-04-27T12:33:46.22+00:00

failed to obtain a response: GET https://management.azure.com/subscriptions/<subID>/providers/Microsoft.Authorization/locks

RESPONSE 404: 404 Not Found ERROR CODE: InvalidResourceType {
"error": { "code": "InvalidResourceType", "message": "The resource type 'locks' could not be found in the namespace 'Microsoft.Authorization' for api version '2020-05-01'. The supported api-versions are '2015-01-01,2015-05-01-preview,2015-06-01,2016-09-01,2017-04-01'." } }

sess, err := azidentity.NewClientSecretCredential(az_tenant_id, az_client_id, az_secret_id, nil)
    if err != nil {
        util.Log.Errorln(err.Error())
    }

    client := armlocks.NewManagementLocksClient(subID, sess, nil)

    page := client.ListAtSubscriptionLevel(&armlocks.ManagementLocksClientListAtSubscriptionLevelOptions{Filter: nil})

    ctx := context.Background()
    util.Log.Errorln("debugging....2")

    for page.NextPage(ctx) {
        resp := page.PageResponse()
        for _, v := range resp.Value {
            util.Log.Errorln(v)
            util.Log.Errorln("debugging....3")
        }
    }

    if err := page.Err(); err != nil {
        util.Log.Errorf("failed to obtain a response: %v", err)
    }
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,504 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. JamesTran-MSFT 36,371 Reputation points Microsoft Employee
    2022-05-05T05:57:10.65+00:00

    @Sunil
    Thank you for your post and I apologize for the delayed response!

    Based off your GET https://management.azure.com/subscriptions/<subID>/providers/Microsoft.Authorization/locks HTTP request and error message, it looks like you're missing the lock name at the end of your request GET ...Microsoft.Authorization/locks/{lockName}?api-version=2016-09-01. For more info.

    Get At Resource Group Level:

    GET https://management.azure.com/subscriptions/subscriptionId/resourceGroups/resourcegroupname/providers/Microsoft.Authorization/locks/testlock?api-version=2016-09-01  
    

    Get At Resource Level:

    GET https://management.azure.com/subscriptions/subscriptionId/resourcegroups/resourcegroupname/providers/Microsoft.Storage/parentResourcePath/storageAccounts/teststorageaccount/providers/Microsoft.Authorization/locks/testlock?api-version=2016-09-01  
    

    Get At Subscription Level:

    GET https://management.azure.com/subscriptions/subscriptionId/providers/Microsoft.Authorization/locks/testlock?api-version=2016-09-01  
    

    Get By Scope:

    GET https://management.azure.com/subscriptions/subscriptionId/providers/Microsoft.Authorization/locks/testlock?api-version=2016-09-01  
    

    I hope this helps!

    If you have any other questions, please let me know.
    Thank you for your time and patience throughout this issue.

    ----------

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    1 person found this answer helpful.
    0 comments No comments

  2. Siva-kumar-selvaraj 15,551 Reputation points
    2022-05-05T10:48:24.753+00:00

    @Sunil ,

    On top of that, as @JamesTran-MSFT pointed out, I also noticed that you posed a similar question on Stackoverflow with the extra detail that you are using azure-sdk in GoLang to access the management API "Microsoft.Authorization/locks" endpoint. The azure-sdk appears to utilize the '2020-05-01' version by default, however this version seems to be not supported by the 'Microsoft.Authorization' namespace.

    For further investigation, I've contacted the Azure-SDK and Service team to find out why the Azure-sdk for GoLang uses an unsupported version of the 'Microsoft.Authorization' namespace.

    Here is GitHub link for this issue, you can also track the status from: https://github.com/Azure/azure-rest-api-specs/issues/18924

    Hope this helps.

    -----
    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    1 person found this answer helpful.