SubscriptionNotFound: The subscription 'resourceGroups' could not be found

余生颓废 提交于 2019-12-14 03:21:20

问题


I'm trying to follow the Resource group authenticate service principal to be able to access some resource manager stuff. But when trying to do anything, I get the following error:

SubscriptionNotFound: The subscription 'resourceGroups' could not be found.

Using the C# code in the article to get an access token, and then calling the follow methods:

    var dnsClient = new DnsManagementClient(new Microsoft.Azure.TokenCloudCredentials(result.AccessToken));

    var zone = dnsClient.Zones.CreateOrUpdate("someresourcegroup", "mydomain.com", new Microsoft.Azure.Management.Dns.Models.ZoneCreateOrUpdateParameters {
            IfNoneMatch = "*",
            Zone = new Microsoft.Azure.Management.Dns.Models.Zone {
                Name = "mydomain.com",
                Location = "northeurope"
            }
        });

Any idea what I'm doing wrong? I've created a service principal as a Contributor, so permissions shouldn't be a problem?


回答1:


The error message says The subscription 'resourceGroups' could not be found, please try specify your subscriptionid when creating the TokenCloudCredentials object.

var dnsClient = new DnsManagementClient(new Microsoft.Azure.TokenCloudCredentials("your_subscriptionid", result.AccessToken));

Tested from my side and it works.



来源:https://stackoverflow.com/questions/35071797/subscriptionnotfound-the-subscription-resourcegroups-could-not-be-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!