Azure Functions:- PowerShell Hashtable to apply App Settings using AzureCLI

Need to apply a list of App Settings to your Azure Function?

Application Settings can be used to store numerous values within your Azure Function, can also be used to store potential passwords.

Application Settings are encrypted at rest and transmitted over an encrypted channel. You can choose to display them in plain text in your browser by using the controls below.

docs.microsoft.com

I’ve created a quick PowerShell Hashtable and foreach loop to apply an array of values.

    $resourceGroup = "tamops-twitter"
    $functionApp = "tamopsfunc"

    $AppSettingsHash = @{
    aPassword = 1
    aPassword2 = 2
    aPassword3 = 3
    }

    foreach ($AppSettingAdd in $AppSettingsHash.GetEnumerator()) {
    az functionapp config appsettings set --resource-group $resourceGroup --name $functionApp --settings "$($AppSettingAdd.Name) = $($AppSettingAdd.Value)"
    }

Apply your list of app settings values into $AppSettingsHash 

The above code will output the snippet below:

  {
    "name": "Password2",
    "slotSetting": false,
    "value": "2"
  },
  {
    "name": "Password3",
    "slotSetting": false,
    "value": "3"
  },
  {
    "name": "Password",
    "slotSetting": false,
    "value": "1"
  }

Now lets review the app settings of function tamopsfunc in the Azure Portal

How do you reference your app settings with an Azure PowerShell Function? Use:

$env: aPassword
$env: aPassword2
$env: aPassword3

Hopefully the above snippet of PowerShell assists you with applying a list of App Settings!

1 thought on “Azure Functions:- PowerShell Hashtable to apply App Settings using AzureCLI

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: