'"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//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'." } }
Following is the code snippet :
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)
}
Solution 1:[1]
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'." } }
- This is already a known issue/feature request, as of now locks are not available for api version
'2020-05-01'
, you can use other supported api-versions i.e.2015-01-01,2015-05-01-preview,2015-06-01,2016-09-01,2017-04-01
.
You can refer to mgmt upgrade service with old api-version, The resource type 'roleAssignments' could not be found in the namespace 'Microsoft.Authorization' for api version '2020-10-01-preview, and Azure Java SDK - Can't add resource locks
Solution 2:[2]
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 your reference: https://github.com/Azure/azure-rest-api-specs/issues/18924
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | sikumars-msft |