如何获得Azure的ResourceManagementClient对象的标签 [英] How to get Tags of Azure ResourceManagementClient object
问题描述
我是想获得资源组标签列表与ResourceManagementClient类。
I' m trying to get tag list of the resource groups with ResourceManagementClient class.
的Microsoft.Azure.Management.Resources 2.14.1- preVIEW的是从添加的软件包管理器控制台的
ResourceManagementClient resourceClient = new ResourceManagementClient(new Microsoft.Azure.CertificateCloudCredentials(SubscriptionId, cert));
var tags = resourceClient.Tags.List();
我得到这个错误;
AuthenticationFailed:验证失败。在授权头不是present或无效的格式提供。
在另一个样本中,部分工作如下;
At another sample, the part is working below;
StorageManagementClient storageClient = new StorageManagementClient(new Microsoft.WindowsAzure.CertificateCloudCredentials(SubscriptionId, cert));
有是这些code部分之间的差。 Microsoft.Azure 用于第一个样本和 Microsoft.WindowsAzure 用于第二和第二抽样工作。
There is a difference between these code parts. Microsoft.Azure is used for first sample and Microsoft.WindowsAzure is used for second and the second sample is working.
如何解决在第一个样品的问题,你能解释一下这个问题?
How can I fix the problem at first sample, can you explain the problem?
推荐答案
我坚信ResourceManagementClient不能与CertificateCloudCredentials工作,在那个是的 ARM REST API 。
我猜你需要先授权使用登录/密码,用户描述<一个href=\"http://www.cloudidentity.com/blog/2014/07/08/USING-ADAL-NET-TO-AUTHENTICATE-USERS-VIA-USERNAMEPASSWORD/\"相对=nofollow>这里然后用获得的令牌ResourceManagementClient
I have strong belief that ResourceManagementClient can't work with CertificateCloudCredentials, at least that was true for ARM Rest API. I guess you need to first authorize user with login/password as described here and then use obtained token with ResourceManagementClient
更新:
第一个环节介绍了如何注册在AD-应用程序可以从门户来完成。
接下来,你需要有寄存器在公元谁将会共同管理员的用户订阅。
之后,获得与第二个链接code认证令牌(使用$ P $光伏步创建的登录/密码)
最后一个使用该令牌ResourceManagementClient授权,这样的事情(不编译):
Update: First link describes how to register application in AD- can be done from the portal. Next you need to have register in AD a user who will be co-administrator for subscription. After that obtain authorization token with code from second link (using login/password created on prev step) An finally use that token for ResourceManagementClient authorization, something like this(does not compile):
var credentials = new TokenCloudCredentials(<subscrtiption id>, <token>);
new ResourceManagerClient(credentials).DoSomething();
这篇关于如何获得Azure的ResourceManagementClient对象的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!