How to add, manage azure function to different development,QA,production environment?

Shruti More 1 Reputation point
2022-03-22T05:27:15.607+00:00

We have a running azure function - forkliftiot which is only for development environment.
Now we want to deploy a seperate function for testing/quality envinonment with code same as development function code except different storage details.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bruno Lucas 4,436 Reputation points MVP
    2022-03-22T09:15:54.31+00:00

    Hi ,
    This will depend on how you structure your code and your azure resources. It's better if you can do it using a devops CI/CD tool, but if you just want a quick way,
    Are you deploying with Visual Studio 2017 or 2019 (https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs?tabs=in-process)?

    Are you passing the storage key though app settings (https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs?tabs=in-process#function-app-settings)?
    The code may have a storage connection string under local.settings.json, once you deploy it will be under the app settings 185527-image.png
    But it could be hardcoded. You need to find and replace with the connection string for the storage used for "Test" (Considering your next environment is Test)

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-use-azure-function-app-settings?tabs=portal

    without devops/automated deployment you can manually create a new storage and new function for test, deploy the same code to the new "TEST" function using the "publish" feature of Visual Studio.

    Do you have your current Azure Function and storage under the same resource group? good tip is to create a new resource group for the next stage. call it "test-[somename]-rg. and add your test function and test storage under it"

    than:

    Go to the new "TEST" storage, grab the key :

    185528-image.png

    and replace on the new "Test" function

    185557-image.png

    Of course there is a lot more to it if you want to improve this process, like organizing in Resource groups with environment prefix, like dev-mycompany-rg, test-mycompany-rg.

    Automation : (to create function app and storage ) https://www.maxivanov.io/deploy-azure-functions-with-terraform/
    (to deploy code) https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-azure-devops?tabs=dotnet-core%2Cyaml%2Ccsharp

    a nice thing to do is to store the storage secret on the azure vault and call the vault in the azure function: https://learn.microsoft.com/en-us/azure/app-service/app-service-key-vault-references

    let me know if you need more details or to expand on it

    0 comments No comments

  2. MughundhanRaveendran-MSFT 12,511 Reputation points
    2022-03-23T16:39:52.677+00:00

    @Shruti More ,

    Thanks for reaching out to Q&A.

    Your function app is running on Linux consumption plan. If you want to use the same code and only use a different storage account, all you need to do is create a new storage account and get its connection string. Under Function app settings, pass the connection string value for the "AzureWebJobsStorage" app setting.

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-app-settings#azurewebjobsstorage

    You can use any deployment method that you prefer.

    I hope this helps! Feel free to reach out to me if you have any questions or concerns.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


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.