How to export and import Azure function's "application settings" ? I have added keys and need to move to new function app. Kindly guide.
You have few options here:
You can do it manually by:
You can use either the azure-cli, powershell, or azure-functions-core-tools to achieve the same thing.
Using the Azure Powershell modules https://learn.microsoft.com/en-us/powershell/azure/overview?view=azurermps-5.4.0
# get the app settings from app1
$resource = Invoke-AzureRmResourceAction -ResourceGroupName <yourResourceGroupName> -ResourceType Microsoft.Web/sites/config -ResourceName "<yourFunctionAppName>/appsettings" -Action list -ApiVersion 2016-08-01 -Force
# update the other app with $resource.Properties
New-AzureRmResource -PropertyObject $resource.Properties -ResourceGroupName <targetResourceGroupName> -ResourceType Microsoft.Web/sites/config -ResourceName "<targetAppName>/appsettings" -ApiVersion 2016-08-01 -Force
The documentation for that tool is here https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local
You can do the same by running
az login
func init myFunctionApp
cd myFunctionApp
# this will fetch your settings and put them in local.settings.json
func azure functionapp fetch-app-settings <yourAppName>
func azure functionapp publish <yourTargetApp> --publish-settings-only
the last switch --publish-settings-only
is important to not overwrite the files if you only want to publish the settings.
https://learn.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest
This page should have some documentation about how to retrieve and set app settings using the cli https://learn.microsoft.com/en-us/azure/app-service/scripts/app-service-cli-app-service-storage?toc=%2fcli%2fazure%2ftoc.json
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With