I have the following in my PowerShell script:
foreach ($row in $csv) {
# split the key into Key Vault name and secret name
$keyParts = $row.key -split '\|'
$functionAppName = $keyParts[0]
$settingName = $keyParts[1]
$value = $row.value
if ($value -match '^https://.*\.vault\.azure\.net/secrets/.*') {
$value = "@Microsoft.KeyVault(SecretUri=$value)"
}
write-host "Setting $settingName for $functionAppName to $value"
az functionapp config appsettings set --resource-group $rg --name $functionAppName --settings "$settingName=$value"
}
The write-host output looks good:
Setting mysetting for myapp to @Microsoft.KeyVault(SecretUri=https://mykv.vault.azure.net/secrets/ServiceBusConnectionString/)
However, when I use the Azure Portal to inspect the value that been inserted I can see that the trailing closing bracket has been truncated - so I have
@Microsoft.KeyVault(SecretUri=https://mykv.vault.azure.net/secrets/ServiceBusConnectionString/
The below
scriptworked for me, try to integrate into your script:Output: