I have a PowerShell script to run an Azure CLI command:
Param (
[parameter(Mandatory = $false)]
[string] $ruleName = "Trusted Device1"
)
az webapp config access-restriction add -g "my-rg" -n "my-app" --rule-name $ruleName --action Allow --ip-address "10.10.10.0/24" --priority 10;
It returns "Bad Request" because $ruleName contains space.
If I run the Azure CLI command directly from PowerShell command window with quoted string, it will work.
az webapp config access-restriction add -g "my-rg" -n "my-app" --rule-name "Trusted device1" --action Allow --ip-address "10.10.10.0/24" --priority 10;
So how do I quote string parameter containing spaces and pass it to Azure CLI command inside a PowerShell script?
Using the following in the script doesn't work
az webapp config access-restriction add -g "my-rg" -n "my-app" --rule-name "$ruleName" --action Allow --ip-address "10.10.10.0/24" --priority 10;