你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

az webapp config access-restriction

显示、设置、添加和删除 Web 应用访问限制的方法。

命令

名称 说明 类型 状态
az webapp config access-restriction add

向 Web 应用添加访问限制。

核心 GA
az webapp config access-restriction remove

从 Web 应用中删除访问限制。

核心 GA
az webapp config access-restriction set

设置 SCM 站点是否使用与主站点相同的限制。

核心 GA
az webapp config access-restriction show

显示 Webapp 的访问限制设置。

核心 GA

az webapp config access-restriction add

向 Web 应用添加访问限制。

az webapp config access-restriction add --priority
                                        [--action {Allow, Deny}]
                                        [--description]
                                        [--http-headers]
                                        [--ids]
                                        [--ignore-missing-endpoint {false, true}]
                                        [--ip-address]
                                        [--name]
                                        [--resource-group]
                                        [--rule-name]
                                        [--scm-site {false, true}]
                                        [--service-tag]
                                        [--slot]
                                        [--subnet]
                                        [--subscription]
                                        [--vnet-name]
                                        [--vnet-resource-group]

示例

将名为 IPv4 地址 130.220.0.0/27 且优先级为 200 的 IPv4 地址的开发人员添加访问限制打开(允许)。

az webapp config access-restriction add -g ResourceGroup -n AppName --rule-name developers --action Allow --ip-address 130.220.0.0/27 --priority 200

为 IPv4 地址 192.168.0.0/27 添加名为build_server的访问限制打开(允许),优先级为 250 到 scm 站点。

az webapp config access-restriction add -g ResourceGroup -n AppName --rule-name build_server --action Allow --ip-address 192.168.0.0/27 --priority 250 --scm-site true

在 vNet core_weu中为子网app_gw添加名为app_gateway的访问限制打开(允许),优先级为 300 的主站点。

az webapp config access-restriction add -g ResourceGroup -n AppName --rule-name app_gateway --action Allow --vnet-name core_weu --subnet app_gateway --priority 300

在 vNet corp01 中为子网build_agents添加名为internal_agents的访问限制打开(允许),优先级为 500 到 scm 站点;并忽略子网上的服务终结点注册。

az webapp config access-restriction add -g ResourceGroup -n AppName --rule-name internal_agents --action Allow --vnet-name corp01 --subnet build_agents --priority 500 --scm-site true --ignore-missing-endpoint true

使用子网“agents”在 rg“vnets”的 vNet“corp01”中添加名为remote_agents的访问限制打开(允许)

az webapp config access-restriction add -g ResourceGroup -n AppName --rule-name remote_agents --action Allow --vnet-name corp01 --subnet agents --priority 500 --vnet-resource-group vnets

使用子网“agents”(使用子网资源 ID)在 rg“vnets”的 vNet“corp01”中添加访问限制打开(允许)命名代理

az webapp config access-restriction add -g ResourceGroup -n AppName --rule-name remote_agents --action Allow --priority 800 --subnet '/subscriptions/<subscription-id>/resourceGroups/vnets/providers/Microsoft.Network/virtualNetworks/corp01/subnets/agents'

添加访问限制打开(允许),没有服务标记 AzureCloud 的规则名称

az webapp config access-restriction add -g ResourceGroup -n AppName --priority 400 --service-tag AzureCloud

添加访问限制打开(允许),服务标记 AzureFrontDoor.Backend 和 http-header X-Azure-FDID 的值为“12345678-abcd-1234-abcd-12345678910a”

az webapp config access-restriction add -g ResourceGroup -n AppName --priority 400 --service-tag AzureFrontDoor.Backend --http-header x-azure-fdid=12345678-abcd-1234-abcd-12345678910a

为同一标头“X-Azure-FDID”添加具有多个 http 标头值的访问限制打开(允许)

az webapp config access-restriction add -g ResourceGroup -n AppName --priority 400 --service-tag AzureFrontDoor.Backend --http-header x-azure-fdid=12345678-abcd-1234-abcd-12345678910a x-azure-fdid=11111111-abcd-1234-abcd-222222222222

必需参数

--priority -p

访问限制规则的优先级。

可选参数

--action

允许或拒绝访问。

接受的值: Allow, Deny
默认值: Allow
--description

访问限制规则的说明。

--http-headers

以空格分隔的 http 标头的格式 <name>=<value>

--ids

一个或多个资源 ID(空格分隔)。 它应该是包含“资源 ID”参数的所有信息的完整资源 ID。 应提供 --id 或其他“资源 ID”参数。

--ignore-missing-endpoint -i

如果子网启用了 Microsoft.Web 服务终结点,请创建具有检查的访问限制规则。

接受的值: false, true
默认值: False
--ip-address

IP 地址或 CIDR 范围(可选逗号分隔列表,最多 8 个范围)。

--name -n

Web 应用的名称。 如果未指定,则会随机生成名称。 可以使用 < a0/a0> 配置默认值 az configure --defaults web=<name>

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--rule-name -r

要添加的访问限制规则的名称。

--scm-site

如此 如果为 scm 站点添加了访问限制。

接受的值: false, true
默认值: False
--service-tag

服务标记(可选逗号分隔列表,最多 8 个标记)。

--slot -s

槽的名称。 如果未指定,则默认为生产槽。

--subnet

子网名称(需要 vNet 名称)或子网资源 ID。

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--vnet-name

VNet 名称。

--vnet-resource-group

虚拟网络的资源组(默认为 Web 应用资源组)。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az webapp config access-restriction remove

从 Web 应用中删除访问限制。

az webapp config access-restriction remove [--action {Allow, Deny}]
                                           [--ids]
                                           [--ip-address]
                                           [--name]
                                           [--resource-group]
                                           [--rule-name]
                                           [--scm-site {false, true}]
                                           [--service-tag]
                                           [--slot]
                                           [--subnet]
                                           [--subscription]
                                           [--vnet-name]

示例

从主站点中删除名为开发人员的访问限制。

az webapp config access-restriction remove -g ResourceGroup -n AppName --rule-name developers

从 scm 站点中删除名为 internal_agents 的访问限制。

az webapp config access-restriction remove -g ResourceGroup -n AppName --rule-name internal_agents --scm-site true

从主站点中删除具有服务标记 AzureFrontDoor.Backend 的访问限制。

az webapp config access-restriction remove -g ResourceGroup -n AppName --service-tag AzureFrontDoor.Backend

可选参数

--action

允许或拒绝访问。

接受的值: Allow, Deny
默认值: Allow
--ids

一个或多个资源 ID(空格分隔)。 它应该是包含“资源 ID”参数的所有信息的完整资源 ID。 应提供 --id 或其他“资源 ID”参数。

--ip-address

IP 地址或 CIDR 范围(可选逗号分隔列表,最多 8 个范围)。

--name -n

Web 应用的名称。 如果未指定,则会随机生成名称。 可以使用 < a0/a0> 配置默认值 az configure --defaults web=<name>

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--rule-name -r

要删除的访问限制的名称。

--scm-site

如此 如果应从 scm 站点中删除访问限制。

接受的值: false, true
默认值: False
--service-tag

服务标记(可选逗号分隔列表,最多 8 个标记)。

--slot -s

槽的名称。 如果未指定,则默认为生产槽。

--subnet

子网名称(需要 vNet 名称)或子网资源 ID。

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--vnet-name

VNet 名称。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az webapp config access-restriction set

设置 SCM 站点是否使用与主站点相同的限制。

az webapp config access-restriction set --use-same-restrictions-for-scm-site {false, true}
                                        [--ids]
                                        [--name]
                                        [--resource-group]
                                        [--slot]
                                        [--subscription]

示例

使 SCM 站点能够使用与主站点相同的访问限制。

az webapp config access-restriction set -g ResourceGroup -n AppName --use-same-restrictions-for-scm-site true

必需参数

--use-same-restrictions-for-scm-site

对 scm 站点使用相同的访问限制。

接受的值: false, true

可选参数

--ids

一个或多个资源 ID(空格分隔)。 它应该是包含“资源 ID”参数的所有信息的完整资源 ID。 应提供 --id 或其他“资源 ID”参数。

--name -n

Web 应用的名称。 如果未指定,则会随机生成名称。 可以使用 < a0/a0> 配置默认值 az configure --defaults web=<name>

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--slot -s

槽的名称。 如果未指定,则默认为生产槽。

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。

az webapp config access-restriction show

显示 Webapp 的访问限制设置。

az webapp config access-restriction show [--ids]
                                         [--name]
                                         [--resource-group]
                                         [--slot]
                                         [--subscription]

示例

获取 Web 应用的访问限制设置。

az webapp config access-restriction show -g ResourceGroup -n AppName

可选参数

--ids

一个或多个资源 ID(空格分隔)。 它应该是包含“资源 ID”参数的所有信息的完整资源 ID。 应提供 --id 或其他“资源 ID”参数。

--name -n

Web 应用的名称。 如果未指定,则会随机生成名称。 可以使用 < a0/a0> 配置默认值 az configure --defaults web=<name>

--resource-group -g

资源组的名称。 可以使用 az configure --defaults group=<name> 配置默认组。

--slot -s

槽的名称。 如果未指定,则默认为生产槽。

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

全局参数
--debug

提高日志记录详细程度以显示所有调试日志。

--help -h

显示此帮助消息并退出。

--only-show-errors

只显示错误,取消显示警告。

--output -o

输出格式。

接受的值: json, jsonc, none, table, tsv, yaml, yamlc
默认值: json
--query

JMESPath 查询字符串。 有关更多信息和示例,请参阅 http://jmespath.org/

--subscription

订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID 配置默认订阅。

--verbose

提高日志记录详细程度。 使用 --debug 获取完整的调试日志。