Not Monitored
Tag not monitored by Microsoft.
41,572 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi Team
When using the "az webapp config access-restriction add" command in an Azure pipeline to create an access restriction rule for a web app showing an below error.
Param(
[Parameter(Mandatory=$true)]
[string]$resourceGroupName,
[Parameter(Mandatory=$true)]
[string]$appServiceName,
[Parameter(Mandatory=$true)]
[string]$ruleName,
[Parameter(Mandatory=$true)]
[string]$serviceTag
)
# Retrieve the access restriction rules for the specified App Service
$accessRules = az webapp config access-restriction show --resource-group $resourceGroupName --name $appServiceName | ConvertFrom-Json
if ($LASTEXITCODE -ne 0) {
throw "Error while fetching access-restriction"
}
# Check if an access restriction rule with the specified name exists
$existingRule = $accessRules.ipSecurityRestrictions | Where-Object { $_.name -eq $ruleName }
if (!$existingRule) {
# Create a new access restriction rule if it doesn't exist
Write-Output "Access restriction rule with name '$ruleName' does not exist. Creating a new rule..."
az webapp config access-restriction add --resource-group $resourceGroupName --name $appServiceName --priority 100 --service-tag $serviceTag --rule-name $ruleName
} else {
# Display a message indicating that the access restriction rule already exists
Write-Output "Access restriction rule with name '$ruleName' already exists."
}