Add-AzWebAppAccessRestrictionRule 在参数"source"上失败,该参数不能为空(尝试使用 -ServiceTag)



尝试从PowerShell为Azure Web App创建访问限制,但cmdlet Add-AzWebAppAccessRestrictionRule失败,返回错误消息"值不能为null。(参数"source"(;。据我所见,没有可以添加到cmdlet的参数"source"-有什么建议吗?

我的代码如下所示,但下面的代码已从实际名称中删除。

Add-AzWebAppAccessRestrictionRule `
  -ResourceGroupName <my-resource-group> `
  -WebAppName <my-web-app-name> `
  -Name FrontDoorServiceTagRule `
  -Priority 100 `
  -Action Allow `
  -ServiceTag AzureFrontDoor.Backend `
  -HttpHeader @{'x-azure-fdid' = '<my-frontdoor-id>'}

正如你在这里提到的,如果你想在Azure DevOps管道AzurePowerShell任务中运行命令,你可以使用AzurePowerShell@7,在DevOps上运行Powershell 7脚本,你可以参考这篇文章。

要在DevOps上运行Powershell 7脚本,您需要明确选择在Azure DevOps中使用Powershell核心(v7.0.3(的选项。Powershell 6以后,它现在被称为Powershell core,并以pwsh.exe的形式启动。Powershell core与Windows Powershell并行运行,默认情况下,当您在Azure DevOps上使用Powershell任务时,它使用普通的Powershell(即v 5.1(。因此,在没有此Powershell的情况下运行时,默认为不具有此功能的普通Powershell.exe。我们可以在Azure DevOps任务上启用Powershell核心,使用该任务的高级设置下的复选框使用Powershell核心并使用并行功能。

最新更新