我正在使用 Microsoft 示例客户端应用程序,该应用程序将图像放在 blob 存储中。
它在我的笔记本电脑上工作,但当我把它放在我的Azure虚拟机Windows服务中时,我得到以下错误。
ERROR: This request is not authorized to perform this operation. - at
Microsoft.Azure.Storage.Core.Executor.Executor.<ExecuteAsync>d__1`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Storage.Blob.CloudBlobContainer.<CreateAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.Storage.Blob.CloudBlobContainer.<CreateIfNotExistsAsync>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
两个IP地址(笔记本电脑和虚拟机)都已被添加到防火墙设置中。
我对两者使用相同的访问密钥。我还尝试了第二个密钥。
string containerName = ContainerPrefix + Guid.NewGuid();
CloudStorageAccount storageAccount = Common.CreateStorageAccountFromConnectionString();
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(containerName);
try
{
BlobRequestOptions requestOptions = new BlobRequestOptions() { RetryPolicy = new NoRetry() };
await container.CreateIfNotExistsAsync(requestOptions, null);
}
catch (StorageException ex)
{
Console.WriteLine($"ERROR: {ex.Message} - {ex.StackTrace}");
Console.ReadLine();
throw;
}
有什么想法?
Gina