简体   繁体   中英

How to upload file in Azure Function app which is deployed through VS2019 and being read from zip?

I am building a web service using Azure Function app V2 using .net core 2.2 stack. My function is working perfectly as per requirement. What i am trying to achieve is function read from JSON file for fetching particular values from it to further process. I am using Visual studio 2019 and publishing app through IDE itself. So my app is in read-mode by default . I have uploaded JSON file in same file as my function file. Also i have tried deleting WEBSITE_RUN_FROM_PACKAGE from config but no luck as it doesnt show function in portal anymore.

When i am running app after publishing the app through VS2019 way (read from zip) making sure that json is in same folder as function file, i am getting an error as follow:

"Could not find file 'D:\home\site\wwwroot\functionname\filename.json'."

I am trying to access file using following code:

var filePath = Path.Combine(context.FunctionDirectory, "filename.json");

According to my test, if we deploy the function to Azure in Visual Studio 2019, we cannot deploy the json file to Azure. We need to manually upload the file to Azure function via kudo.

  1. Deploy the Function to Azure in Visual Studion 在此处输入图像描述

  2. Upload the file to Azure Function via kudu 在此处输入图像描述 在此处输入图像描述 在此处输入图像描述

Besides, if your file is too big, I suggest you store the file in Azure Blob storage then use the blob in your function. For more details, please refer to the document .

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