Amry
Amry

Reputation: 4971

How to bind CloudStorageAccount input to Azure Function?

My simplified code sample

I have the following simplified Azure Function code built in Visual Studio 2017:

public static class FunctionApp
{
    [FunctionName("MyFunction")]
    public static void Run(
        [TimerTrigger("0 */5 * * * *")] TimerInfo myTimer,
        [StorageAccount("ConnectionString")] CloudStorageAccount storage)
    {}
}

With the following connection string

I have already added a key "AzureWebJobsConnectionString" to the file local.settings.json for development test purpose. However I'm getting the following error message when debugging:

Error indexing method 'FunctionApp.Run' Microsoft.Azure.WebJobs.Host: Error indexing method 'FunctionApp.Run'. Microsoft.Azure.WebJobs.Host: Invalid storage account ''. Please make sure your credentials are correct.

The added connection string form is as following:

BlobEndpoint=https://******.blob.core.windows.net;SharedAccessSignature=sv=2017-04-17&ss=b&srt=sco&sp=dl&se=2099-12-31T00:00:00Z&st=2017-10-22T00:00:00Z&spr=https&sig=******

And also tested in Azure

Then I configured a connection string named "AzureWebJobsConnectionString" in the Azure Function Portal's Application Settings to test it in Azure, but no success story.

But still without success :(

How do I get the CloudStorageAccount to properly bind to the Azure Function?

Upvotes: 2

Views: 1607

Answers (1)

Roman Kiss
Roman Kiss

Reputation: 8235

Go to the azure portal storage/Settings/Access_keys to take a Connection String.

The format is

DefaultEndpointsProtocol=https;AccountName=<youraccountname>‌​;AccountKey=<youracc‌​ountkey>;EndpointSuf‌​fix=core.windows.net

Upvotes: 1

Related Questions