Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easy way to export AppSettings for an Azure Web App?

Is there an easy way to export all the AppSettings for each of my Web Apps in every App Service Plan for a given Resource Group?

I've currently got about 20 apps running under different App Service Plans for a given Resource Group and I'm in the process of creating an Azure Resource Manager (ARM) template for easy allocation/dellocation of resources and I've found that the "Automation Script" feature to be largely helpful but it doesn't seem to export any of the AppSettings I've added via the Webapp's Application Settings blade within the Azure Portal.

enter image description here

enter image description here

like image 423
Frank Fu Avatar asked Oct 24 '17 00:10

Frank Fu


People also ask

How do I export my Azure app Configuration?

From the Azure portal, follow these steps: Browse to your App Configuration store, and select Import/export. On the Export tab, select Configuration file under Target service.

Does Azure use Appsettings JSON?

config or appsettings. json and production secrets (for example, Azure MySQL database password) safely in App Service. The same code uses your development settings when you debug locally, and it uses your production secrets when deployed to Azure.

How do I get Azure app Configuration connection string?

You can find the connection string under Access Keys of your App Configuration store in the Azure portal.


2 Answers

You can download the App settings in different ways. Few are using Kudu Console/Resource Explorer/PowerShell.

To access the site through the Kudu console, use the below URL. https://****.scm.azurewebsites.net/ (enter your website name instead of ****)

Goto App Settings -> download

enter image description here

You can also download this from ‘Resource explorer’ option available in Azure Portal.

Goto Web App -> Development Tools -> Resource explorer -> select the resource -> download the settings

Below PowerShell cmdlets will also help you to download the App Settings.

$app = Get-AzureRmWebApp -ResourceGroupName YourRGName -Name YourAppName
$app.SiteConfig.AppSettings
$app.SiteConfig.ConnectionStrings

For more details on how to use PowerShell for Web Apps, refer: Azure PowerShell Samples

You may also check the blog post how to Export Azure WebApp Application Settings & Configuration Strings To CSV

Hope this helps.

like image 193
AshokPeddakotla-MSFT Avatar answered Nov 11 '22 02:11

AshokPeddakotla-MSFT


In response to @Ashok's post I've created a powershell script which loops through every single Resource Group's App Service and exports the each app service's app settings to a CSV file.

$allWebApps = Get-AzureRmWebApp
$resourceGroups = $allWebApps | Select-Object 'ResourceGroup' -Unique
foreach($r in $resourceGroups)
{
    $rgName = $r.ResourceGroup    
    $webApps = Get-AzureRmWebApp -ResourceGroupName $rgName

    foreach($w in $webApps)
    {
        $webAppName = $w.Name        
        Write-Host Processing Webapp : $webAppName

        $webApp = Get-AzureRmWebApp -ResourceGroupName $rgName -Name $webAppName
        $appSettings = $webApp.SiteConfig.AppSettings

        # Extract AppSettings to CSV
        $appSettings.GetEnumerator() | 
                Sort-Object -Property Name -Descending |
                Select-Object -Property @{n='Key';e={$_.Name}},Value |
                Export-Csv -Path C:\Azure\$webAppName.csv -NoTypeInformation -Append

    }    
}

I wish there was a nicer way to do this though. I might just add that it has been voiced (somewhat) in the Azure's Feedback Forum's for Azure Resource Manager. If anyone feels it's a useful feature, please cast your votes in the feedback.

like image 31
Frank Fu Avatar answered Nov 11 '22 04:11

Frank Fu