SubscriptionNotFound: The subscription 'resour

2019-09-10 03:18发布

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条回答
可以哭但决不认输i
2楼-- · 2019-09-10 03:31

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.

查看更多
登录 后发表回答