如何将CloudStorageAccount输入绑定到Azure函数? [英] How to bind CloudStorageAccount input to Azure Function?
问题描述
我在Visual Studio 2017中内置了以下简化的Azure函数代码:
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)
{}
}
具有以下连接字符串
我已经在文件local.settings.json中添加了键" AzureWebJobsConnectionString ",用于开发测试.但是,调试时出现以下错误消息:
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:
错误索引方法'FunctionApp.Run'Microsoft.Azure.WebJobs.Host: 错误索引方法'FunctionApp.Run'. Microsoft.Azure.WebJobs.Host: 无效的存储帐户".请确保您的凭据是 正确.
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 = ******
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=******
并且也在Azure中进行了测试
然后,我在Azure函数门户的应用程序设置中配置了一个名为"AzureWebJobsConnectionString"的连接字符串,以便在Azure中对其进行测试,但是没有成功的故事.
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.
如何使CloudStorageAccount正确绑定到Azure函数?
How do I get the CloudStorageAccount to properly bind to the Azure Function?
推荐答案
转到Azure门户 storage/Settings/Access_keys 以获取连接字符串.
Go to the azure portal storage/Settings/Access_keys to take a Connection String.
格式为
DefaultEndpointsProtocol=https;AccountName=<youraccountname>;AccountKey=<youraccountkey>;EndpointSuffix=core.windows.net
这篇关于如何将CloudStorageAccount输入绑定到Azure函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!