Wednesday, March 01, 2017

How to set storage account connection string in Azure Functions


I was developing an Azure Function App that connects to an Azure blob storage. After setting up the binding for my blob storage account. I got the following error message when running my function app:

The error message in the screen shot above suggests three options to fix this. I will walk through how to implement the first option as one of the available solutions. The first solution is to set the connection string name in the appsettings.json file so it will look like this.

  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "AzureWebJobsDashboard": "",
    "AzureWebJobsmofunctions_STORAGE": "DefaultEndpointsProtocol=https;AccountName=mofunctions;AccountKey=KEY"

function.json (Just a section where i define my blob binding info)

      "type": "blob",
      "name": "iBlob",
      "path": "mydata/file1.csv",
      "connection": "mofunctions_STORAGE",
      "direction": "in"

You will notice that the connection name value in function.json is a suffix for AzureWebJobs key in the appsettings.json file.

Once you set this, Press F5 and you will be able to connect and read blob contents from Azure storage accounts.


No comments: