简体   繁体   中英

Blob binding in httpTrigger not working in VS2017 Azure function template

I want to pass the filename of blob to the httptrigger, through get request as below.

http://localhost:7071/api/CSVDataMigrationHttpTrigger/testdata.csv

Code for the azure function

public static async Task<HttpResponseMessage> Run(
        [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "CSVDataMigrationHttpTrigger/{name}")]
        HttpRequest req, string name,
        [Blob("csvdata-upload/{name}", FileAccess.Read, Connection = "AzureWebJobsStorage")]
        Stream inputBlob, ILogger log)
    {}

inputBlob parameter is not resolved and it returns null.

But if i give filename as "testData.csv" as below in the Blob parameter, then inputBlob get resolved properly.

  public static async Task<HttpResponseMessage> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "CSVDataMigrationHttpTrigger/{name}")]
            HttpRequest req, string name,
            [Blob("csvdata-upload/testData.csv", FileAccess.Read, Connection = "AzureWebJobsStorage")]
            Stream inputBlob, ILogger log){}

I found out finally, the filename was case sensitive, when passed to blob. Hope it helps anyone who has the same issue.

Check whether your blob is actually uploaded in the Storage Container. The stream will be null only if the blob is Not Exist / Unable to find in the container

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM