首页 > 解决方案 > Az Command powershell 用于在 azure app 服务的 CORS 中添加 url

问题描述

我正在寻找 az commands (powershell) 以在部署时在 azure app 服务中添加 url

为了清楚起见,您可以参考随附的图像。 在此处输入图像描述

提前致谢

标签: azurepowershellazure-web-app-serviceaz

解决方案


请使用Set-AzResource

一个例子供你参考。

$webAppName = ""
$subscriptionId = ""
$tenantId = ""
$resourceGroup = ""

Connect-AzAccount -Tenant $tenantId
Select-AzSubscription -SubscriptionId $subscriptionId

$allowedOrigins = @()
$allowedOrigins += "www.example.com"

$PropertiesObject = @{cors = @{allowedOrigins= $allowedOrigins}}

Set-AzResource -PropertyObject $PropertiesObject -ResourceGroupName $resourceGroup -ResourceType Microsoft.Web/sites/config -ResourceName $webAppName/web -ApiVersion 2015-08-01 -Force

推荐阅读