SubscriptionNotFound:找不到订阅"resourceGroups" [英] SubscriptionNotFound: The subscription 'resourceGroups' could not be found

查看:249
本文介绍了SubscriptionNotFound:找不到订阅"resourceGroups"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循资源组对服务主体进行身份验证,以便能够访问某些资源管理器中的内容.但是,当尝试执行任何操作时,出现以下错误:

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:找不到订阅"resourceGroups".

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

使用本文中的C#代码获取访问令牌,然后调用以下方法:

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?

推荐答案

错误消息显示找不到订阅'resourceGroups',请在创建 TokenCloudCredentials时尝试指定您的subscriptionid 对象.

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.

这篇关于SubscriptionNotFound:找不到订阅"resourceGroups"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆