We recommend using Azure Native.
azure.mssql.VirtualNetworkRule
Explore with Pulumi AI
Allows you to manage rules for allowing traffic between an Azure SQL server and a subnet of a virtual network.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
const example = new azure.core.ResourceGroup("example", {
name: "example-sql-server-vnet-rule",
location: "West Europe",
});
const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", {
name: "example-vnet",
addressSpaces: ["10.7.29.0/29"],
location: example.location,
resourceGroupName: example.name,
});
const exampleSubnet = new azure.network.Subnet("example", {
name: "example-subnet",
resourceGroupName: example.name,
virtualNetworkName: exampleVirtualNetwork.name,
addressPrefixes: ["10.7.29.0/29"],
serviceEndpoints: ["Microsoft.Sql"],
});
const exampleServer = new azure.mssql.Server("example", {
name: "uniqueazuresqlserver",
resourceGroupName: example.name,
location: example.location,
version: "12.0",
administratorLogin: "4dm1n157r470r",
administratorLoginPassword: "4-v3ry-53cr37-p455w0rd",
});
const exampleVirtualNetworkRule = new azure.mssql.VirtualNetworkRule("example", {
name: "sql-vnet-rule",
serverId: exampleServer.id,
subnetId: exampleSubnet.id,
});
import pulumi
import pulumi_azure as azure
example = azure.core.ResourceGroup("example",
name="example-sql-server-vnet-rule",
location="West Europe")
example_virtual_network = azure.network.VirtualNetwork("example",
name="example-vnet",
address_spaces=["10.7.29.0/29"],
location=example.location,
resource_group_name=example.name)
example_subnet = azure.network.Subnet("example",
name="example-subnet",
resource_group_name=example.name,
virtual_network_name=example_virtual_network.name,
address_prefixes=["10.7.29.0/29"],
service_endpoints=["Microsoft.Sql"])
example_server = azure.mssql.Server("example",
name="uniqueazuresqlserver",
resource_group_name=example.name,
location=example.location,
version="12.0",
administrator_login="4dm1n157r470r",
administrator_login_password="4-v3ry-53cr37-p455w0rd")
example_virtual_network_rule = azure.mssql.VirtualNetworkRule("example",
name="sql-vnet-rule",
server_id=example_server.id,
subnet_id=example_subnet.id)
package main
import (
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/core"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/mssql"
"github.com/pulumi/pulumi-azure/sdk/v6/go/azure/network"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := core.NewResourceGroup(ctx, "example", &core.ResourceGroupArgs{
Name: pulumi.String("example-sql-server-vnet-rule"),
Location: pulumi.String("West Europe"),
})
if err != nil {
return err
}
exampleVirtualNetwork, err := network.NewVirtualNetwork(ctx, "example", &network.VirtualNetworkArgs{
Name: pulumi.String("example-vnet"),
AddressSpaces: pulumi.StringArray{
pulumi.String("10.7.29.0/29"),
},
Location: example.Location,
ResourceGroupName: example.Name,
})
if err != nil {
return err
}
exampleSubnet, err := network.NewSubnet(ctx, "example", &network.SubnetArgs{
Name: pulumi.String("example-subnet"),
ResourceGroupName: example.Name,
VirtualNetworkName: exampleVirtualNetwork.Name,
AddressPrefixes: pulumi.StringArray{
pulumi.String("10.7.29.0/29"),
},
ServiceEndpoints: pulumi.StringArray{
pulumi.String("Microsoft.Sql"),
},
})
if err != nil {
return err
}
exampleServer, err := mssql.NewServer(ctx, "example", &mssql.ServerArgs{
Name: pulumi.String("uniqueazuresqlserver"),
ResourceGroupName: example.Name,
Location: example.Location,
Version: pulumi.String("12.0"),
AdministratorLogin: pulumi.String("4dm1n157r470r"),
AdministratorLoginPassword: pulumi.String("4-v3ry-53cr37-p455w0rd"),
})
if err != nil {
return err
}
_, err = mssql.NewVirtualNetworkRule(ctx, "example", &mssql.VirtualNetworkRuleArgs{
Name: pulumi.String("sql-vnet-rule"),
ServerId: exampleServer.ID(),
SubnetId: exampleSubnet.ID(),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Azure = Pulumi.Azure;
return await Deployment.RunAsync(() =>
{
var example = new Azure.Core.ResourceGroup("example", new()
{
Name = "example-sql-server-vnet-rule",
Location = "West Europe",
});
var exampleVirtualNetwork = new Azure.Network.VirtualNetwork("example", new()
{
Name = "example-vnet",
AddressSpaces = new[]
{
"10.7.29.0/29",
},
Location = example.Location,
ResourceGroupName = example.Name,
});
var exampleSubnet = new Azure.Network.Subnet("example", new()
{
Name = "example-subnet",
ResourceGroupName = example.Name,
VirtualNetworkName = exampleVirtualNetwork.Name,
AddressPrefixes = new[]
{
"10.7.29.0/29",
},
ServiceEndpoints = new[]
{
"Microsoft.Sql",
},
});
var exampleServer = new Azure.MSSql.Server("example", new()
{
Name = "uniqueazuresqlserver",
ResourceGroupName = example.Name,
Location = example.Location,
Version = "12.0",
AdministratorLogin = "4dm1n157r470r",
AdministratorLoginPassword = "4-v3ry-53cr37-p455w0rd",
});
var exampleVirtualNetworkRule = new Azure.MSSql.VirtualNetworkRule("example", new()
{
Name = "sql-vnet-rule",
ServerId = exampleServer.Id,
SubnetId = exampleSubnet.Id,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.azure.core.ResourceGroup;
import com.pulumi.azure.core.ResourceGroupArgs;
import com.pulumi.azure.network.VirtualNetwork;
import com.pulumi.azure.network.VirtualNetworkArgs;
import com.pulumi.azure.network.Subnet;
import com.pulumi.azure.network.SubnetArgs;
import com.pulumi.azure.mssql.Server;
import com.pulumi.azure.mssql.ServerArgs;
import com.pulumi.azure.mssql.VirtualNetworkRule;
import com.pulumi.azure.mssql.VirtualNetworkRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new ResourceGroup("example", ResourceGroupArgs.builder()
.name("example-sql-server-vnet-rule")
.location("West Europe")
.build());
var exampleVirtualNetwork = new VirtualNetwork("exampleVirtualNetwork", VirtualNetworkArgs.builder()
.name("example-vnet")
.addressSpaces("10.7.29.0/29")
.location(example.location())
.resourceGroupName(example.name())
.build());
var exampleSubnet = new Subnet("exampleSubnet", SubnetArgs.builder()
.name("example-subnet")
.resourceGroupName(example.name())
.virtualNetworkName(exampleVirtualNetwork.name())
.addressPrefixes("10.7.29.0/29")
.serviceEndpoints("Microsoft.Sql")
.build());
var exampleServer = new Server("exampleServer", ServerArgs.builder()
.name("uniqueazuresqlserver")
.resourceGroupName(example.name())
.location(example.location())
.version("12.0")
.administratorLogin("4dm1n157r470r")
.administratorLoginPassword("4-v3ry-53cr37-p455w0rd")
.build());
var exampleVirtualNetworkRule = new VirtualNetworkRule("exampleVirtualNetworkRule", VirtualNetworkRuleArgs.builder()
.name("sql-vnet-rule")
.serverId(exampleServer.id())
.subnetId(exampleSubnet.id())
.build());
}
}
resources:
example:
type: azure:core:ResourceGroup
properties:
name: example-sql-server-vnet-rule
location: West Europe
exampleVirtualNetwork:
type: azure:network:VirtualNetwork
name: example
properties:
name: example-vnet
addressSpaces:
- 10.7.29.0/29
location: ${example.location}
resourceGroupName: ${example.name}
exampleSubnet:
type: azure:network:Subnet
name: example
properties:
name: example-subnet
resourceGroupName: ${example.name}
virtualNetworkName: ${exampleVirtualNetwork.name}
addressPrefixes:
- 10.7.29.0/29
serviceEndpoints:
- Microsoft.Sql
exampleServer:
type: azure:mssql:Server
name: example
properties:
name: uniqueazuresqlserver
resourceGroupName: ${example.name}
location: ${example.location}
version: '12.0'
administratorLogin: 4dm1n157r470r
administratorLoginPassword: 4-v3ry-53cr37-p455w0rd
exampleVirtualNetworkRule:
type: azure:mssql:VirtualNetworkRule
name: example
properties:
name: sql-vnet-rule
serverId: ${exampleServer.id}
subnetId: ${exampleSubnet.id}
Create VirtualNetworkRule Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new VirtualNetworkRule(name: string, args: VirtualNetworkRuleArgs, opts?: CustomResourceOptions);
@overload
def VirtualNetworkRule(resource_name: str,
args: VirtualNetworkRuleArgs,
opts: Optional[ResourceOptions] = None)
@overload
def VirtualNetworkRule(resource_name: str,
opts: Optional[ResourceOptions] = None,
server_id: Optional[str] = None,
subnet_id: Optional[str] = None,
ignore_missing_vnet_service_endpoint: Optional[bool] = None,
name: Optional[str] = None)
func NewVirtualNetworkRule(ctx *Context, name string, args VirtualNetworkRuleArgs, opts ...ResourceOption) (*VirtualNetworkRule, error)
public VirtualNetworkRule(string name, VirtualNetworkRuleArgs args, CustomResourceOptions? opts = null)
public VirtualNetworkRule(String name, VirtualNetworkRuleArgs args)
public VirtualNetworkRule(String name, VirtualNetworkRuleArgs args, CustomResourceOptions options)
type: azure:mssql:VirtualNetworkRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args VirtualNetworkRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args VirtualNetworkRuleArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args VirtualNetworkRuleArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args VirtualNetworkRuleArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args VirtualNetworkRuleArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var virtualNetworkRuleResource = new Azure.MSSql.VirtualNetworkRule("virtualNetworkRuleResource", new()
{
ServerId = "string",
SubnetId = "string",
IgnoreMissingVnetServiceEndpoint = false,
Name = "string",
});
example, err := mssql.NewVirtualNetworkRule(ctx, "virtualNetworkRuleResource", &mssql.VirtualNetworkRuleArgs{
ServerId: pulumi.String("string"),
SubnetId: pulumi.String("string"),
IgnoreMissingVnetServiceEndpoint: pulumi.Bool(false),
Name: pulumi.String("string"),
})
var virtualNetworkRuleResource = new VirtualNetworkRule("virtualNetworkRuleResource", VirtualNetworkRuleArgs.builder()
.serverId("string")
.subnetId("string")
.ignoreMissingVnetServiceEndpoint(false)
.name("string")
.build());
virtual_network_rule_resource = azure.mssql.VirtualNetworkRule("virtualNetworkRuleResource",
server_id="string",
subnet_id="string",
ignore_missing_vnet_service_endpoint=False,
name="string")
const virtualNetworkRuleResource = new azure.mssql.VirtualNetworkRule("virtualNetworkRuleResource", {
serverId: "string",
subnetId: "string",
ignoreMissingVnetServiceEndpoint: false,
name: "string",
});
type: azure:mssql:VirtualNetworkRule
properties:
ignoreMissingVnetServiceEndpoint: false
name: string
serverId: string
subnetId: string
VirtualNetworkRule Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The VirtualNetworkRule resource accepts the following input properties:
- Server
Id string - The resource ID of the SQL Server to which this SQL virtual network rule will be applied. Changing this forces a new resource to be created.
- Subnet
Id string - The ID of the subnet from which the SQL server will accept communications.
- Ignore
Missing boolVnet Service Endpoint Create the virtual network rule before the subnet has the virtual network service endpoint enabled. Defaults to
false
.NOTE: If
ignore_missing_vnet_service_endpoint
is false, and the target subnet does not contain theMicrosoft.SQL
endpoint in theservice_endpoints
array, the deployment will fail when it tries to create the SQL virtual network rule.- Name string
- The name of the SQL virtual network rule. Changing this forces a new resource to be created.
- Server
Id string - The resource ID of the SQL Server to which this SQL virtual network rule will be applied. Changing this forces a new resource to be created.
- Subnet
Id string - The ID of the subnet from which the SQL server will accept communications.
- Ignore
Missing boolVnet Service Endpoint Create the virtual network rule before the subnet has the virtual network service endpoint enabled. Defaults to
false
.NOTE: If
ignore_missing_vnet_service_endpoint
is false, and the target subnet does not contain theMicrosoft.SQL
endpoint in theservice_endpoints
array, the deployment will fail when it tries to create the SQL virtual network rule.- Name string
- The name of the SQL virtual network rule. Changing this forces a new resource to be created.
- server
Id String - The resource ID of the SQL Server to which this SQL virtual network rule will be applied. Changing this forces a new resource to be created.
- subnet
Id String - The ID of the subnet from which the SQL server will accept communications.
- ignore
Missing BooleanVnet Service Endpoint Create the virtual network rule before the subnet has the virtual network service endpoint enabled. Defaults to
false
.NOTE: If
ignore_missing_vnet_service_endpoint
is false, and the target subnet does not contain theMicrosoft.SQL
endpoint in theservice_endpoints
array, the deployment will fail when it tries to create the SQL virtual network rule.- name String
- The name of the SQL virtual network rule. Changing this forces a new resource to be created.
- server
Id string - The resource ID of the SQL Server to which this SQL virtual network rule will be applied. Changing this forces a new resource to be created.
- subnet
Id string - The ID of the subnet from which the SQL server will accept communications.
- ignore
Missing booleanVnet Service Endpoint Create the virtual network rule before the subnet has the virtual network service endpoint enabled. Defaults to
false
.NOTE: If
ignore_missing_vnet_service_endpoint
is false, and the target subnet does not contain theMicrosoft.SQL
endpoint in theservice_endpoints
array, the deployment will fail when it tries to create the SQL virtual network rule.- name string
- The name of the SQL virtual network rule. Changing this forces a new resource to be created.
- server_
id str - The resource ID of the SQL Server to which this SQL virtual network rule will be applied. Changing this forces a new resource to be created.
- subnet_
id str - The ID of the subnet from which the SQL server will accept communications.
- ignore_
missing_ boolvnet_ service_ endpoint Create the virtual network rule before the subnet has the virtual network service endpoint enabled. Defaults to
false
.NOTE: If
ignore_missing_vnet_service_endpoint
is false, and the target subnet does not contain theMicrosoft.SQL
endpoint in theservice_endpoints
array, the deployment will fail when it tries to create the SQL virtual network rule.- name str
- The name of the SQL virtual network rule. Changing this forces a new resource to be created.
- server
Id String - The resource ID of the SQL Server to which this SQL virtual network rule will be applied. Changing this forces a new resource to be created.
- subnet
Id String - The ID of the subnet from which the SQL server will accept communications.
- ignore
Missing BooleanVnet Service Endpoint Create the virtual network rule before the subnet has the virtual network service endpoint enabled. Defaults to
false
.NOTE: If
ignore_missing_vnet_service_endpoint
is false, and the target subnet does not contain theMicrosoft.SQL
endpoint in theservice_endpoints
array, the deployment will fail when it tries to create the SQL virtual network rule.- name String
- The name of the SQL virtual network rule. Changing this forces a new resource to be created.
Outputs
All input properties are implicitly available as output properties. Additionally, the VirtualNetworkRule resource produces the following output properties:
- Id string
- The provider-assigned unique ID for this managed resource.
- Id string
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
- id string
- The provider-assigned unique ID for this managed resource.
- id str
- The provider-assigned unique ID for this managed resource.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing VirtualNetworkRule Resource
Get an existing VirtualNetworkRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: VirtualNetworkRuleState, opts?: CustomResourceOptions): VirtualNetworkRule
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
ignore_missing_vnet_service_endpoint: Optional[bool] = None,
name: Optional[str] = None,
server_id: Optional[str] = None,
subnet_id: Optional[str] = None) -> VirtualNetworkRule
func GetVirtualNetworkRule(ctx *Context, name string, id IDInput, state *VirtualNetworkRuleState, opts ...ResourceOption) (*VirtualNetworkRule, error)
public static VirtualNetworkRule Get(string name, Input<string> id, VirtualNetworkRuleState? state, CustomResourceOptions? opts = null)
public static VirtualNetworkRule get(String name, Output<String> id, VirtualNetworkRuleState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Ignore
Missing boolVnet Service Endpoint Create the virtual network rule before the subnet has the virtual network service endpoint enabled. Defaults to
false
.NOTE: If
ignore_missing_vnet_service_endpoint
is false, and the target subnet does not contain theMicrosoft.SQL
endpoint in theservice_endpoints
array, the deployment will fail when it tries to create the SQL virtual network rule.- Name string
- The name of the SQL virtual network rule. Changing this forces a new resource to be created.
- Server
Id string - The resource ID of the SQL Server to which this SQL virtual network rule will be applied. Changing this forces a new resource to be created.
- Subnet
Id string - The ID of the subnet from which the SQL server will accept communications.
- Ignore
Missing boolVnet Service Endpoint Create the virtual network rule before the subnet has the virtual network service endpoint enabled. Defaults to
false
.NOTE: If
ignore_missing_vnet_service_endpoint
is false, and the target subnet does not contain theMicrosoft.SQL
endpoint in theservice_endpoints
array, the deployment will fail when it tries to create the SQL virtual network rule.- Name string
- The name of the SQL virtual network rule. Changing this forces a new resource to be created.
- Server
Id string - The resource ID of the SQL Server to which this SQL virtual network rule will be applied. Changing this forces a new resource to be created.
- Subnet
Id string - The ID of the subnet from which the SQL server will accept communications.
- ignore
Missing BooleanVnet Service Endpoint Create the virtual network rule before the subnet has the virtual network service endpoint enabled. Defaults to
false
.NOTE: If
ignore_missing_vnet_service_endpoint
is false, and the target subnet does not contain theMicrosoft.SQL
endpoint in theservice_endpoints
array, the deployment will fail when it tries to create the SQL virtual network rule.- name String
- The name of the SQL virtual network rule. Changing this forces a new resource to be created.
- server
Id String - The resource ID of the SQL Server to which this SQL virtual network rule will be applied. Changing this forces a new resource to be created.
- subnet
Id String - The ID of the subnet from which the SQL server will accept communications.
- ignore
Missing booleanVnet Service Endpoint Create the virtual network rule before the subnet has the virtual network service endpoint enabled. Defaults to
false
.NOTE: If
ignore_missing_vnet_service_endpoint
is false, and the target subnet does not contain theMicrosoft.SQL
endpoint in theservice_endpoints
array, the deployment will fail when it tries to create the SQL virtual network rule.- name string
- The name of the SQL virtual network rule. Changing this forces a new resource to be created.
- server
Id string - The resource ID of the SQL Server to which this SQL virtual network rule will be applied. Changing this forces a new resource to be created.
- subnet
Id string - The ID of the subnet from which the SQL server will accept communications.
- ignore_
missing_ boolvnet_ service_ endpoint Create the virtual network rule before the subnet has the virtual network service endpoint enabled. Defaults to
false
.NOTE: If
ignore_missing_vnet_service_endpoint
is false, and the target subnet does not contain theMicrosoft.SQL
endpoint in theservice_endpoints
array, the deployment will fail when it tries to create the SQL virtual network rule.- name str
- The name of the SQL virtual network rule. Changing this forces a new resource to be created.
- server_
id str - The resource ID of the SQL Server to which this SQL virtual network rule will be applied. Changing this forces a new resource to be created.
- subnet_
id str - The ID of the subnet from which the SQL server will accept communications.
- ignore
Missing BooleanVnet Service Endpoint Create the virtual network rule before the subnet has the virtual network service endpoint enabled. Defaults to
false
.NOTE: If
ignore_missing_vnet_service_endpoint
is false, and the target subnet does not contain theMicrosoft.SQL
endpoint in theservice_endpoints
array, the deployment will fail when it tries to create the SQL virtual network rule.- name String
- The name of the SQL virtual network rule. Changing this forces a new resource to be created.
- server
Id String - The resource ID of the SQL Server to which this SQL virtual network rule will be applied. Changing this forces a new resource to be created.
- subnet
Id String - The ID of the subnet from which the SQL server will accept communications.
Import
SQL Virtual Network Rules can be imported using the resource id
, e.g.
$ pulumi import azure:mssql/virtualNetworkRule:VirtualNetworkRule rule1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.Sql/servers/myserver/virtualNetworkRules/vnetrulename
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- Azure Classic pulumi/pulumi-azure
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
azurerm
Terraform Provider.