gpt4 book ai didi

azure - 如何访问本地 PC 上的模拟 Azure 存储

转载 作者:行者123 更新时间:2023-12-01 10:30:32 28 4
gpt4 key购买 nike

我开始使用 Azure 函数进行开发。我已经能够连接到我的实际 Azure 存储帐户队列,以测试如何使用 Azure 函数进行编程。现在,我的下一步是使用 Microsoft Azure 存储资源管理器来使用本地存储帐户,这样我就不必连接到 azure。我在这篇文章中看到了如何做到这一点:https://learn.microsoft.com/en-us/azure/storage/storage-configure-connection-string#create-a-connection-string-to-the-storage-emulator

in the appsettings.json I changed my values to this exactly:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==",
"AzureWebJobsDashboard": "",
"StorageConnectionString": "UseDevelopmentStorage=true"

}
}

当我使用 Visual Studio 启动 Azure Fuctions CLI 时,我收到此错误消息:

ScriptHost initialization failed Microsoft.WindowsAzure.Storage: The remote server returned an error: (403) Forbidden.

有人遇到过这种情况吗?

最佳答案

请更改以下代码行:

"AzureWebJobsStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

到:

"AzureWebJobsStorage": "UseDevelopmentStorage=true"

或者:

"AzureWebJobsStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;
AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;
BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;
TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;
QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;"

这应该可以解决 403 错误。

基本上,存储模拟器具有与云存储帐户不同的端点。例如,云存储帐户的默认 Blob 终结点是 http://[youraccount].blob.core.windows.net而存储模拟器的 blob 端点是 http://127.0.0.1:10000 。当您仅在连接字符串中指定存储模拟器的存储帐户名称和 key 时,存储客户端库会将其视为云存储帐户并尝试连接到 http://devstoreaccount1.blob.core.windows.net使用您提供的帐户 key 。由于云中 devstoreaccount1 的 key 不是您提供的 key ,因此您会收到 403 错误。

关于azure - 如何访问本地 PC 上的模拟 Azure 存储,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43217898/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com