Sending file share/bob storage path and Key vault values to Azure Function POST body

Jeevi Danda 71 Reputation points
2022-10-14T17:35:58.833+00:00

Hi,

In my azure function (developed by using Java), I need to read files from a location and process those files based on my custom code. While developing this, I used files from my local directory. But I want to deploy this application to Cloud and want to read files from the file share or blob storage. How I can send my file share/blob storage path as a parameter in the request body.

Local Path:
{
"inputFile": "C:/Users/Desktop/abc.txt"
}

Expected file share path once deployed:
{
"inputFile": "/archive/abc.txt"
}

Here archive is one of the file share from my storage account. How Can provide my file share/blob storage access to my azure function, so it can access all the files on the file share/blob storage. Also, I am trying to pass the key value secrets to my azure function as well. Please suggest how I can achieve this.

Example:

251232-image.png

In this example, I am passing my input and output streams as part of post body and trying to read those paths in my code. I am getting file/path not found exception if I directly pass the blob storage path as an input.

Thanks,
Jeevi

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
0 comments No comments
{count} votes

Answer accepted by question author
  1. MuthuKumaranMurugaachari-MSFT 22,446 Reputation points Moderator
    2022-10-18T15:48:07.67+00:00

    @Jeevi Danda Thank you for reaching out to Microsoft Q&A. Based on your statement, you need help in reading files or blobs from Storage account in your Function app code (Java).

    FileInputStream can be used to read files that are either in local (during development) or azure deployment path such as "/home/site/wwwroot/". However, for reading files or blobs from azure storage account, you would need to use Azure SDK for Java v12 library and samples are available at https://learn.microsoft.com/en-us/azure/storage/common/storage-samples-java. Refer Blob samples or File samples respectively for your scenario.

    I am not sure about the need to pass Key Vault secrets in the request body. You can use Key Vault references in Azure Functions and refer Use Key Vault references for App Service and Azure Functions for more info on this. If this doesn't match your needs, please clarify and it would help to understand better.

    We would be happy to assist you for any questions and upvote if it helped.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Stefano Demiliani 166 Reputation points MVP
    2022-10-18T12:38:25.957+00:00

    You can use Azure Storage File Shares client library for .NET for reading your azure file share from Azure Functions:
    https://learn.microsoft.com/en-us/dotnet/api/overview/azure/storage.files.shares-readme?view=azure-dotnet

    Credentials to access the file share can be stored in your function code, in config files or (better) on Azure KeyVault.
    From an Azure Function accessing an Azure file share you can read the files content exactly like in your local development environment. When you have the content, you can process the file accordingly.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.