Share via


Microsoft.Sql servers/administrators

Bicep resource definition

The servers/administrators resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Sql/servers/administrators resource, add the following Bicep to your template.

resource symbolicname 'Microsoft.Sql/servers/administrators@2024-11-01-preview' = {
  parent: resourceSymbolicName
  name: 'string'
  properties: {
    administratorType: 'string'
    login: 'string'
    sid: 'string'
    tenantId: 'string'
  }
}

Property Values

Microsoft.Sql/servers/administrators

Name Description Value
name The resource name 'ActiveDirectory' (required)
parent In Bicep, you can specify the parent resource for a child resource. You only need to add this property when the child resource is declared outside of the parent resource.

For more information, see Child resource outside parent resource.
Symbolic name for resource of type: servers
properties Resource properties. AdministratorProperties

AdministratorProperties

Name Description Value
administratorType Type of the sever administrator. 'ActiveDirectory'
login Login name of the server administrator. string (required)
sid SID (object ID) of the server administrator. string

Constraints:
Min length = 36
Max length = 36
Pattern = ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$ (required)
tenantId Tenant ID of the administrator. string

Constraints:
Min length = 36
Max length = 36
Pattern = ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$

Usage Examples

Bicep Samples

A basic example of deploying SQL Server Administrators.

param resourceName string = 'acctest0001'
param location string = 'westeurope'
@secure()
@description('The administrator login password for the SQL server')
param administratorLoginPassword string

resource server 'Microsoft.Sql/servers@2015-05-01-preview' = {
  name: resourceName
  location: location
  properties: {
    administratorLogin: 'mradministrator'
    administratorLoginPassword: null
    version: '12.0'
  }
}

resource administrator 'Microsoft.Sql/servers/administrators@2020-11-01-preview' = {
  parent: server
  name: 'ActiveDirectory'
  properties: {
    administratorType: 'ActiveDirectory'
    login: 'sqladmin'
    sid: deployer().objectId
    tenantId: deployer().tenantId
  }
}

ARM template resource definition

The servers/administrators resource type can be deployed with operations that target:

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Sql/servers/administrators resource, add the following JSON to your template.

{
  "type": "Microsoft.Sql/servers/administrators",
  "apiVersion": "2024-11-01-preview",
  "name": "string",
  "properties": {
    "administratorType": "string",
    "login": "string",
    "sid": "string",
    "tenantId": "string"
  }
}

Property Values

Microsoft.Sql/servers/administrators

Name Description Value
apiVersion The api version '2024-11-01-preview'
name The resource name 'ActiveDirectory' (required)
properties Resource properties. AdministratorProperties
type The resource type 'Microsoft.Sql/servers/administrators'

AdministratorProperties

Name Description Value
administratorType Type of the sever administrator. 'ActiveDirectory'
login Login name of the server administrator. string (required)
sid SID (object ID) of the server administrator. string

Constraints:
Min length = 36
Max length = 36
Pattern = ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$ (required)
tenantId Tenant ID of the administrator. string

Constraints:
Min length = 36
Max length = 36
Pattern = ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$

Usage Examples

Terraform (AzAPI provider) resource definition

The servers/administrators resource type can be deployed with operations that target:

  • Resource groups

For a list of changed properties in each API version, see change log.

Resource format

To create a Microsoft.Sql/servers/administrators resource, add the following Terraform to your template.

resource "azapi_resource" "symbolicname" {
  type = "Microsoft.Sql/servers/administrators@2024-11-01-preview"
  name = "string"
  parent_id = "string"
  body = {
    properties = {
      administratorType = "string"
      login = "string"
      sid = "string"
      tenantId = "string"
    }
  }
}

Property Values

Microsoft.Sql/servers/administrators

Name Description Value
name The resource name 'ActiveDirectory' (required)
parent_id The ID of the resource that is the parent for this resource. ID for resource of type: servers
properties Resource properties. AdministratorProperties
type The resource type "Microsoft.Sql/servers/administrators@2024-11-01-preview"

AdministratorProperties

Name Description Value
administratorType Type of the sever administrator. 'ActiveDirectory'
login Login name of the server administrator. string (required)
sid SID (object ID) of the server administrator. string

Constraints:
Min length = 36
Max length = 36
Pattern = ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$ (required)
tenantId Tenant ID of the administrator. string

Constraints:
Min length = 36
Max length = 36
Pattern = ^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$

Usage Examples

Terraform Samples

A basic example of deploying SQL Server Administrators.

terraform {
  required_providers {
    azapi = {
      source = "Azure/azapi"
    }
    azurerm = {
      source = "hashicorp/azurerm"
    }
  }
}

provider "azurerm" {
  features {
  }
}

provider "azapi" {
  skip_provider_registration = false
}

variable "resource_name" {
  type    = string
  default = "acctest0001"
}

variable "location" {
  type    = string
  default = "westeurope"
}

variable "administrator_login_password" {
  type        = string
  description = "The administrator login password for the SQL server"
  sensitive   = true
}

data "azurerm_client_config" "current" {
}

resource "azapi_resource" "resourceGroup" {
  type     = "Microsoft.Resources/resourceGroups@2020-06-01"
  name     = var.resource_name
  location = var.location
}

resource "azapi_resource" "server" {
  type      = "Microsoft.Sql/servers@2015-05-01-preview"
  parent_id = azapi_resource.resourceGroup.id
  name      = var.resource_name
  location  = var.location
  body = {
    properties = {
      administratorLogin         = "mradministrator"
      administratorLoginPassword = var.administrator_login_password
      version                    = "12.0"
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}

resource "azapi_resource" "administrator" {
  type      = "Microsoft.Sql/servers/administrators@2020-11-01-preview"
  parent_id = azapi_resource.server.id
  name      = "ActiveDirectory"
  body = {
    properties = {
      administratorType = "ActiveDirectory"
      login             = "sqladmin"
      sid               = data.azurerm_client_config.current.client_id
      tenantId          = data.azurerm_client_config.current.tenant_id
    }
  }
  schema_validation_enabled = false
  response_export_values    = ["*"]
}