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!

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s