question

Sunil-8972 avatar image
0 Votes"
Sunil-8972 asked JamesTran-MSFT commented

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

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)
     }
azure-ad-microsoft-account
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JamesTran-MSFT avatar image
1 Vote"
JamesTran-MSFT answered

@Sunil-8972
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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

sikumars-msft avatar image
1 Vote"
sikumars-msft answered JamesTran-MSFT commented

@Sunil-8972,

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.



· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@sikumars-msft
Thank you for adding to this!

@Sunil-8972, if you have any other questions, please let us 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 Vote 1 ·

@Sunil-8972
I just wanted to check in and see if you had any other questions or if you were able to resolve this issue?

0 Votes 0 ·