Azure functions 读取Blob存储Azure函数HttpTrigger

Azure functions 读取Blob存储Azure函数HttpTrigger,azure-functions,Azure Functions,尽管在这里或其他地方有很多帖子,我仍然没有找到如何从azure函数读取blob存储 我有以下建议 上述每个容器都有一个json文件“customer.json” 现在我需要调用我的函数并传递一个参数,例如“london”,以检索london客户 Customer customer= await azureFunctionService.GetCustomer(“London”); 函数应该是什么样子,理想情况下,我希望使用输入绑定从函数中读取json文件,但任何其他方法都可以

尽管在这里或其他地方有很多帖子,我仍然没有找到如何从azure函数读取blob存储

我有以下建议

上述每个容器都有一个json文件“customer.json”

现在我需要调用我的函数并传递一个参数,例如“london”,以检索london客户

Customer customer= await azureFunctionService.GetCustomer(“London”);
函数应该是什么样子,理想情况下,我希望使用输入绑定从函数中读取json文件,但任何其他方法都可以

        [FunctionName("GetCustomer")]
        public static void Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            string inputBlobPath,
            [Blob("howDoIBuildPathIncludingtheparameter", 
                FileAccess.Read, Connection = "WhereDoIGetThis")] string json,
            ILogger log)
        {
            // Not sure if anything is required here apart from logging when using input binding
            //
        }
有什么建议吗


非常感谢您尝试了以下代码。 下面的示例是一个C#函数,它使用队列触发器和输入blob绑定。队列消息包含blob的名称,函数记录blob的大小

[FunctionName("BlobInput")]
public static void Run(
    [QueueTrigger("myqueue-items")] string myQueueItem,
    [Blob("samples-workitems/{queueTrigger}", FileAccess.Read)] Stream myBlob,
    ILogger log)
{
    log.LogInformation($"BlobInput processed blob\n Name:{myQueueItem} \n Size: {myBlob.Length} bytes");

}

此Microsoft文档提供了一个简单示例,说明如何从
HttpTrigger
提取数据以填充blob的输入绑定路径:

如上所述,单独定义有效负载对象,然后将此类型与
HttpTrigger
属性一起使用。然后,对象属性可在其他输入绑定表达式中引用

公共类BlobInfo
{
公共字符串CityName{get;set;}
}
公共静态类GetCustomer
{
[函数名(“GetCustomer”)]
公共静态异步任务运行(
[HttpTrigger(AuthorizationLevel.Function,“post”,Route=null)]BlobInfo信息,
[Blob(“{CityName}/customer.json”,FileAccess.Read)]流Blob,
ILogger日志)
{
使用指定所需城市名称的JSON负载调用此函数,例如
curlhttp://localhost:7071/api/GetCustomer -d“{'CityName':'manchester'}”


这将使用名为“manchester”且标题为“customer.json”的容器中的blob内容初始化blob输入参数。

您使用的是Azure函数2还是greater@maxspanHi是版本3。默认情况下,我使用Visual studio 2019 16.5创建该函数。非常感谢您的帮助。我不知道它使用的是“QueueTrigger”而不是HttpTrigger,在我的例子中,我应该在这里放什么“samples workitems/{queueTrigger}”,你会如何更改它以适应我的情况。如果你愿意,我需要取消syntaxt,请用Httptriggerok替换QueueTriggerok,我在我的问题中做过,但这里的语法是什么[Blob(“samples workitems/{queueTrigger}”如果我的blobstoragename=london,filename=customer.json,我不想硬编码,那么在函数中属性如何读取它?您需要在路由值中传递它