我曾尝试下面的代码来创建在Azure中的新存储帐户:天青 - 编程创建存储帐户
获取令牌(成功 - 我收到一个令牌):
var cc = new ClientCredential("clientId", "clientSecret");
var context = new AuthenticationContext("https://login.windows.net/subscription");
var result = context.AcquireTokenAsync("https://management.azure.com/", cc);
创建云存储凭据:
var credential = new TokenCloudCredentials("subscription", token);
创建云存储账户(失败):
using (var storageClient = new StorageManagementClient(credentials))
{
await storageClient.StorageAccounts.CreateAsync(new StorageAccountCreateParameters
{
Label = "samplestorageaccount",
Location = LocationNames.NorthEurope,
Name = "myteststorage",
AccountType = "RA-GRS"
});
}
错误:
ForbiddenError: The server failed to authenticate the request. Verify that the certificate is valid and is associated with this subscription.
我不知道这是否是那些误导性消息中的一个,或者如果我错误地配置在Azure中的东西吗?
请看看这个回答你的问题:https://stackoverflow.com/questions/35190866/error-making-azure-management-library-api-call-when-authenticating-with-azure-ac/ 35194706#35194706。 –
@GauravMantri非常感谢 - 该链接提供了获取正确标识符的见解 –