在Visual Studio中开发Azure功能时无效的存储帐户

时间:2017-09-21 04:37:45

标签: c# azure visual-studio-2017 azure-storage azure-functions

我正在使用C#在Visual Studio中开发Azure功能。我在我的开发机器上本地运行它,它位于代理后面。但是不断收到此错误:

Exception binding parameter Invalid storage account Please make sure your credentials are correct

在我的C#类中,我有以下函数,它具有绑定到Service Bus队列的输出。

[FunctionName("MyTestFunction")]        
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req, [Queue("myqueue")]IAsyncCollector<string> myQueue, TraceWriter log)

在local.settings.json中,我使用从Azure存储资源管理器复制的连接字符串填充AzureWebJobsStorage和AzureWebJobsDashboard

{    
  "IsEncrypted": false,  
  "Values": {"AzureWebJobsStorage":"DefaultEndpointsProtocol=https;AccountName=storageaccountname;AccountKey=sNFYlzkTtIVejJqU36rhByzDq91Nyv+JQ==;BlobEndpoint=https://storageaccount.blob.core.windows.net/;QueueEndpoint=https://storageaccount.queue.core.windows.net/;TableEndpoint=https://storageaccount.table.core.windows.net/;FileEndpoint=https://storageaccount.file.core.windows.net/;",
"AzureWebJobsDashboard": "DefaultEndpointsProtocol=https;AccountName=storageaccountname;AccountKey=sNFYlzkTtIVejJqU36rhByzDq91Nyv+JQ==;BlobEndpoint=https://storageaccount.blob.core.windows.net/;QueueEndpoint=https://storageaccount.queue.core.windows.net/;TableEndpoint=https://storageaccount.table.core.windows.net/;FileEndpoint=https://storageaccount.file.core.windows.net/;"
  }
}

它对我有用了一段时间,但后来停止了一起工作。我三重检查了一切,仍然无法弄清楚我做错了什么。有人能指出我正确的方向吗?

我对AzureWebJobsStorage和AzureWebJobsDashboard的值是从Azure Storage Explorer中我的存储帐户的主连接字符串直接复制的。

2 个答案:

答案 0 :(得分:2)

我有类似的错误消息:

  

缺少存储机密凭据。

document之后,我使用Azure Functions CLI(func.exe)(命令行界面)更新了local.settings.json中所有必需的凭据。

  1. 确保您拥有node.js
  2. 如果尚未安装Azure CLI,请安装:npm install -g azure-functions-core-tools
  3. 在您的Azure Functions v2项目根目录中,执行func azure functionapp fetch-app-settings myawesomefunctionappname
  4. 您应该在local.settings.js中看到自己的凭据得到更新。本地调试可能要求您具有未加密的凭据。只需在该文件中设置IsEncrypted: false

这里是一个示例:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=...",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "APPINSIGHTS_INSTRUMENTATIONKEY": "...",
    "FUNCTIONS_EXTENSION_VERSION": "~2",
    "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "DefaultEndpointsProtocol=https;AccountName=...",
    "WEBSITE_CONTENTSHARE": "...",
    "WEBSITE_NODE_DEFAULT_VERSION": "8.11.1",
    "WEBSITE_LOAD_CERTIFICATES": "*",
    "WEBSITE_RUN_FROM_PACKAGE": "1"
  },
  "ConnectionStrings": {}
}

答案 1 :(得分:0)

对于遇到相同问题的人 - 在代理后面本地(使用Visual Studio)开发Azure功能。

以下是我修复问题的方法 - 在func.exe.Config中添加代理设置。您将能够在C:\Users\{yourAccountName}\AppData\Local\Azure.Functions.Cli\1.0.0\func.exe.Config

下找到该文件

将您的代理设置添加为:

<system.net>
<defaultProxy useDefaultCredentials="true">
  <proxy usesystemdefault="True" proxyaddress="http://my.proxy.com:8080" bypassonlocal="True" autoDetect="True" />
</defaultProxy>
</system.net>

希望这有助于某人。

我真的希望返回的错误消息实际告诉我们CLI实际上无法连接到Azure,而不是一直告诉我我使用了无效的存储帐户。

相关问题