'how to export and import Azure Function's "application settings"
How to export and import Azure function's "application settings" ? I have added keys and need to move to new function app. Kindly guide.
Solution 1:[1]
Currently, it is impossible. You could check this feedback.
One solution, you could clone your web app, see this link. When you clone a app, application settings are also cloned.
Another solution, you could use Power Shell to import application setting and copy the application to a new web app, using following example:
try{
$acct = Get-AzureRmSubscription
}
catch{
Login-AzureRmAccount
}
$myResourceGroup = '<your resource group>'
$mySite = '<your web app>'
$myResourceGroup2 = '<another resource group>'
$mySite2 = '<another web app>'
$props = (Invoke-AzureRmResourceAction -ResourceGroupName $myResourceGroup `
-ResourceType Microsoft.Web/sites/Config -Name $mySite/appsettings `
-Action list -ApiVersion 2015-08-01 -Force).Properties
$hash = @{}
$props | Get-Member -MemberType NoteProperty | % { $hash[$_.Name] = $props.($_.Name) }
Set-AzureRMWebApp -ResourceGroupName $myResourceGroup2 `
-Name $mySite2 -AppSettings $hash
More information about this please check this answer
Solution 2:[2]
Another option is to use Postman.
You can get a JSON with all app settings by making a GET request to the following URL:
https://$AZURE_LOGIN:$AZURE_PASS@$FUNCTION_APPNAME.scm.azurewebsites.net/api/settings
Once the keys are returned you can make a POST request to the new function app's URL and copy that JSON result as the request body with a header Content-Type: application/json.
Username and password can be found from Deployment Credentials in the portal of your Function App.
Solution 3:[3]
You can also get them via the Azure portal:
- Select your Functions App in the Azure portal.
- Click Download app content in the top bar.
- Select Include app settings in the download
- Find the file
local.settings.jsonin the download.
Solution 4:[4]
I think Oliver's answer is the easiest one, but just in case, I had the need of retrieving the local.settings.json formatted file from a specific slot (not the root app) that also has keyvault secrets.
So I created this script that gets the configs from an app or a slot app, formats them as a local.settings.json file and if there are keyvaults, it also resolves the values.
I hope it can help somebody, but actually, downloading the app content gives you the file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Aaron Chen |
| Solution 3 | Oliver Bock |
| Solution 4 | Maximiliano Rodriguez |
