如何创建publicNetworkAccess字段为null的Azure SQL Server逻辑服务器
如何创建Azure SQL Server使
publicNetworkAccess字段值为null publicNetworkAccess字段显示为null的核心是创建服务器时不主动指定该属性的值,让Azure采用早期的隐式默认逻辑。如果显式设置Enabled或Disabled,该字段就会对应显示这两个值;只有完全不配置这个属性,才会返回null。
以下是几种主流创建方式的操作示例:
Azure CLI 创建
执行命令时不要添加--public-network-access参数:
az sql server create \ --name your-server-name \ --resource-group your-resource-group \ --location eastus \ --admin-user your-admin-account \ --admin-password your-secure-password
ARM 模板 创建
在模板的properties区块中不包含publicNetworkAccess字段,示例片段:
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "serverName": { "type": "string" }, "location": { "type": "string" }, "administratorLogin": { "type": "string" }, "administratorLoginPassword": { "type": "securestring" } }, "resources": [ { "type": "Microsoft.Sql/servers", "apiVersion": "2020-02-02-preview", "name": "[parameters('serverName')]", "location": "[parameters('location')]", "properties": { "administratorLogin": "[parameters('administratorLogin')]", "administratorLoginPassword": "[parameters('administratorLoginPassword')]", "version": "12.0" // 此处不要添加publicNetworkAccess配置 } } ] }
PowerShell 创建
执行命令时不指定-PublicNetworkAccess参数:
New-AzSqlServer -ResourceGroupName "your-resource-group" ` -ServerName "your-server-name" ` -Location "eastus" ` -SqlAdministratorCredentials (Get-Credential)
注意事项
- 建议使用相对早期的Azure SQL API版本(比如2020-02-02-preview及之前),新版本API可能会默认将该字段设为
Enabled,即使不主动配置也不会返回null。 - 创建完成后,可通过
az sql server show等命令查询服务器属性,确认publicNetworkAccess字段是否为null。
内容的提问来源于stack exchange,提问作者Jonas Zerbib
相关产品推荐
相关产品推荐

