简体   繁体   中英

Can use a different blob storage connection string in my azure function (c#) depending if I am in dev or prod?

I built an azure function that gets an XML file from a POST request, converts it to JSON and uploads it to an azure blob storage container. Currently I just have the connection string to the container hard coded within my function. However the issue is, the file needs to be uploaded to a different container depending whether the dev or prod deployment of the function is being used.

var connectionString = "sampleConnectionString";
    BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
    var containerNameXML = "sampleContainerName";
    BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerNameXML);
    BlobClient blobClient = containerClient.GetBlobClient(xmlFileName);      

I know I can store the connection string in a local.settings.json file and access it in the code, but that would only be for one of the environments. So I am wondering if it is possible to overwrite the local environment variable via azure for each environment or something similar.

Thank you in advance for any advice.

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