此请求无权执行此操作。我使用 class "BlobServiceClient" 连接

This request is not authorized to perform this operation. I used the class "BlobServiceClient" to connect

我已经阅读了与我遇到的问题相同的页面。

我设置了IP,在我使用class“CloudStorageAccount”后,我可以连接到Azure Storage。
但我想使用另一个 class “BlobContainerClient”,它用作连接到 Azure 模拟器“Azurite”的示例代码。
https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azurite#azure-blob-storage
我可以在 Docker 中成功连接到 Azurite。 但是当我更改连接字符串以连接到真正的 Azure Blob 存储时,我只会收到错误“此请求未被授权执行此操作。”。

var client = new BlobContainerClient(
new Uri("https://myaccount.blob.core.windows.net/container"),
new StorageSharedKeyCredential("myaccount", $"{AccountKey}"));

这是我的连接字符串的样子。如何使用此 class 连接到 Azure 存储?或者我不应该使用这个 class?

使用“选择的网络”时,由于某些原因,比如你使用的是vpn或代理等,azure检测到的客户端ip有时不是很准确。

所以你可以使用这个cmd命令来找到你的真实客户端ip:curl -L ip.tool.lu。然后手动将其添加到您的 Azure 门户中。它在我身边工作。