az sql server vnet-rule

Manage a server's virtual network rules.

Commands

az sql server vnet-rule create Create a virtual network rule to allows access to an Azure SQL server.
az sql server vnet-rule delete Deletes the virtual network rule with the given name.
az sql server vnet-rule list Gets a list of virtual network rules in a server.
az sql server vnet-rule show Gets a virtual network rule.
az sql server vnet-rule update Update a virtual network rule.

az sql server vnet-rule create

Create a virtual network rule to allows access to an Azure SQL server.

az sql server vnet-rule create --name
--resource-group
--server
--subnet
[--ignore-missing-endpoint {false, true}]
[--subscription]
[--vnet-name]

Examples

Create a vnet rule by providing the subnet id.

az sql server vnet-rule create --server MyAzureSqlServer --name MyVNetRule \
  -g MyResourceGroup --subnet /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Network/virtualNetworks/{VNETName}/subnets/{SubnetName}

Create a vnet rule by providing the vnet and subnet name. The subnet id is created by taking the resource group name and subscription id of the SQL server.

az sql server vnet-rule create --server MyAzureSqlServer --name MyVNetRule \
    -g MyResourceGroup --subnet subnetName --vnet-name vnetName

Required Parameters

--name -n

The name of the virtual network rule.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--server -s

Name of the Azure SQL server. You can configure the default using az configure --defaults sql-server=<name>.

--subnet

Name or ID of the subnet that allows access to an Azure Sql Server. If subnet name is provided, --vnet-name must be provided.

Optional Parameters

--ignore-missing-endpoint -i

Create firewall rule before the virtual network has vnet service endpoint enabled.

accepted values: false, true
--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

--vnet-name

The virtual network name.

az sql server vnet-rule delete

Deletes the virtual network rule with the given name.

az sql server vnet-rule delete --name
[--ids]
[--resource-group]
[--server]
[--subscription]

Required Parameters

--name -n

The name of the virtual network rule.

Optional Parameters

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--server -s

Name of the Azure SQL server. You can configure the default using az configure --defaults sql-server=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az sql server vnet-rule list

Gets a list of virtual network rules in a server.

az sql server vnet-rule list [--ids]
[--resource-group]
[--server]
[--subscription]

Optional Parameters

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--server -s

Name of the Azure SQL server. You can configure the default using az configure --defaults sql-server=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az sql server vnet-rule show

Gets a virtual network rule.

az sql server vnet-rule show --name
[--ids]
[--resource-group]
[--server]
[--subscription]

Required Parameters

--name -n

The name of the virtual network rule.

Optional Parameters

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--server -s

Name of the Azure SQL server. You can configure the default using az configure --defaults sql-server=<name>.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.

az sql server vnet-rule update

Update a virtual network rule.

az sql server vnet-rule update --name
--subnet
[--add]
[--force-string]
[--ids]
[--ignore-missing-endpoint {false, true}]
[--remove]
[--resource-group]
[--server]
[--set]
[--subscription]

Required Parameters

--name -n

The name of the virtual network rule.

--subnet

Name or ID of the subnet that allows access to an Azure Sql Server. If subnet name is provided, --vnet-name must be provided.

Optional Parameters

--add

Add an object to a list of objects by specifying a path and key value pairs. Example: --add property.listProperty <key=value, string or JSON string>.

--force-string

When using 'set' or 'add', preserve string literals instead of attempting to convert to JSON.

--ids

One or more resource IDs (space-delimited). If provided, no other 'Resource Id' arguments should be specified.

--ignore-missing-endpoint -i

Create firewall rule before the virtual network has vnet service endpoint enabled.

accepted values: false, true
--remove

Remove a property or an element from a list. Example: --remove property.list OR --remove propertyToRemove.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--server -s

Name of the Azure SQL server. You can configure the default using az configure --defaults sql-server=<name>.

--set

Update an object by specifying a property path and value to set. Example: --set property1.property2=.

--subscription

Name or ID of subscription. You can configure the default subscription using az account set -s NAME_OR_ID.