CreateIfNotExistsAsync - 此请求未被授权执行此操作。

问题描述 投票:0回答:1

我正在使用 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

azure azure-storage azure-storage-blobs azure-virtual-machine
1个回答
0
投票

尝试允许从.NET网络访问,以消除IP地址的可能性。所有网络,以消除IP地址问题的可能性。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.