1
votes

I'm developing Azure Function in Visual Studio using C#. And I'n running it locally on my development machine which sits behind a proxy. However keep getting this error:

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

In my C# class I have following function which have an output binding to a Service Bus queue.

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

In local.settings.json, I populated AzureWebJobsStorage and AzureWebJobsDashboard with connection string copied from Azure Storage Explorer

{    
  "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/;"
  }
}

It worked for me for a while, but then stopped working all together. I triple checked everything and still couldn't figure out what I did wrong. Can someone point me to the right direction for this please?

The value I have for AzureWebJobsStorage and AzureWebJobsDashboard are straight copy from the Primary Connection String of my storage account in Azure Storage Explorer.

2
It looks like we throw that exception explicitly if we think the password is incorrect. Are you able to use that same key in another application -- such as Storage Explorer -- and connect successfully?brettsam
Yes. Azure Storage Explorer connect fine, that how I manage to copy the Primary Connection String from there. I should also mention, I'm running this on my local machine and it is behind a proxy.p31415926
Some other things to try: Another account? Try outside the proxy? Try deploying to Azure and see if it works? If it's not the password, it'll help to isolate where it's breaking.brettsam
brettsam, apart from setting the correct Connection String in AzureWebJobsStorage and AzureWebJobsDashboard, what else I need to setup to have my solution correctly authenticated against Azure? I've tried another storage account, have the exactly same problem. It would take some efforts to get it tested outside the proxy which something I will try over the weekend.p31415926
Manage to move my solution to machine with direct internet connection. The problem gone away straightaway. I can conclude it is a proxy issue. My question now is how do I properly set the proxy for this to work?p31415926

2 Answers

2
votes

I had a similar error message:

Missing storage secret credentials.

Following this document, I used the Azure Functions CLI (func.exe) (Command Line Interface) to update all necessary credentials in my local.settings.json.

  1. Ensure you have node.js
  2. Install Azure CLI if not already done so: npm install -g azure-functions-core-tools
  3. In your Azure Functions v2 project root directory, execute func azure functionapp fetch-app-settings myawesomefunctionappname
  4. You should see your credentials getting updated in local.settings.js. Local debugging might require you to have non-encrypted credentials. Simply set IsEncrypted: false in that file.

Here's a sample:

{
  "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": {}
}
0
votes

For those experiencing the same problem - developing Azure Functions locally (using Visual Studio) behind a proxy.

Here is how I fixed the issue - adding proxy settings in the func.exe.Config. You will be able to find the file under C:\Users\{yourAccountName}\AppData\Local\Azure.Functions.Cli\1.0.0\func.exe.Config

Add your proxy settings as:

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

Hope this helps someone.

I really wish the error message returned actually tells us the CLI is actually not able to connect to Azure, rather than keep telling me I'm using an invalid storage account.