Azure SQL Database servers and their management
What is an Azure SQL Database server
A SQL Database server is a logical construct that acts as a central administrative point for multiple single or pooled databases, logins, firewall rules, auditing rules, threat detection policies, and failover groups A SQL Database server can be in a different region than its resource group. The SQL Database server must exist before you can create the Azure SQL database. All databases managed by a SQL Database server are created within the same region as the SQL Database server.
A SQL Database server is distinct from a SQL Server instance that you may be familiar with in the on-premises world. Specifically, the SQL Database service makes no guarantees regarding location of the databases in relation to the SQL Database server that manages them, and exposes no instance-level access or features. In contrast, the instance databases in a managed instance are all co-located - in the same way that you are familiar with SQL Server in the on-premises world.
When you create a SQL Database server, you provide a server login account and password that has administrative rights to the master database on that server and all databases created on that server. This initial account is a SQL login account. Azure SQL Database supports SQL authentication and Azure Active Directory Authentication for authentication. For information about logins and authentication, see Managing Databases and Logins in Azure SQL Database. Windows Authentication is not supported.
A SQL Database server:
- Is created within an Azure subscription, but can be moved with its contained resources to another subscription
- Is the parent resource for databases, elastic pools, and data warehouses
- Provides a namespace for databases, elastic pools, and data warehouses
- Is a logical container with strong lifetime semantics - delete a server and it deletes the contained databases, elastic pools, and data warehouses
- Participates in Azure role-based access control (RBAC) - databases, elastic pools, and data warehouses within a server inherit access rights from the server
- Is a high-order element of the identity of databases, elastic pools, and data warehouses for Azure resource management purposes (see the URL scheme for databases and pools)
- Collocates resources in a region
- Provides a connection endpoint for database access (
- Provides access to metadata regarding contained resources via DMVs by connecting to a master database
- Provides the scope for management policies that apply to its databases - logins, firewall, audit, threat detection, and such
- Is restricted by a quota within the parent subscription (six servers per subscription by default - see Subscription limits here)
- Provides the scope for database quota and DTU or vCore quota for the resources it contains (such as 45,000 DTU)
- Is the versioning scope for capabilities enabled on contained resources
- Server-level principal logins can manage all databases on a server
- Can contain logins similar to those in instances of SQL Server on your premises that are granted access to one or more databases on the server, and can be granted limited administrative rights. For more information, see Logins.
- The default collation for all databases created on a SQL Database server is
LATIN1_GENERALis English (United States),
CP1is code page 1252,
CIis case-insensitive, and
Manage Azure SQL servers, databases, and firewalls using the Azure portal
You can create the Azure SQL database's resource group ahead of time or while creating the server itself. There are multiple methods for getting to a new SQL server form, either by creating a new SQL server or as part of creating a new database.
Create a blank SQL Database server
To create an Azure SQL Database server (without a database) using the Azure portal, navigate to a blank SQL server (logical server) form.
Create a blank or sample SQL database
To create an Azure SQL database using the Azure portal, navigate to a blank SQL Database form and provide the requested information. You can create the Azure SQL database's resource group and SQL Database server ahead of time or while creating the database itself. You can create a blank database or create a sample database based on Adventure Works LT.
To create a managed instance, see Create a managed instance
Manage an existing SQL server
To manage an existing server, navigate to the server using a number of methods - such as from specific SQL database page, the SQL servers page, or the All resources page.
To manage an existing database, navigate to the SQL databases page and click the database you wish to manage. The following screenshot shows how to begin setting a server-level firewall for a database from the Overview page for a database.
For an Azure portal quickstart, see Create an Azure SQL database in the Azure portal.
Manage Azure SQL servers, databases, and firewalls using PowerShell
This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. For Az module installation instructions, see Install Azure PowerShell.
The PowerShell Azure Resource Manager module is still supported by Azure SQL Database, but all future development is for the Az.Sql module. For these cmdlets, see AzureRM.Sql. The arguments for the commands in the Az module and in the AzureRm modules are substantially identical.
To create and manage Azure SQL server, databases, and firewalls with Azure PowerShell, use the following PowerShell cmdlets. If you need to install or upgrade PowerShell, see Install Azure PowerShell module. For creating and managing elastic pools, see Elastic pools.
|New-AzSqlDatabase||Creates a database|
|Get-AzSqlDatabase||Gets one or more databases|
|Set-AzSqlDatabase||Sets properties for a database, or moves an existing database into an elastic pool|
|Remove-AzSqlDatabase||Removes a database|
|New-AzResourceGroup||Creates a resource group|
|New-AzSqlServer||Creates a server|
|Get-AzSqlServer||Returns information about servers|
|Set-AzSqlServer||Modifies properties of a server|
|Remove-AzSqlServer||Removes a server|
|New-AzSqlServerFirewallRule||Creates a server-level firewall rule|
|Get-AzSqlServerFirewallRule||Gets firewall rules for a server|
|Set-AzSqlServerFirewallRule||Modifies a firewall rule in a server|
|Remove-AzSqlServerFirewallRule||Deletes a firewall rule from a server.|
|New-AzSqlServerVirtualNetworkRule||Creates a virtual network rule, based on a subnet that is a Virtual Network service endpoint.|
For a PowerShell quickstart, see Create an Azure SQL single database using PowerShell. For PowerShell example scripts, see Use PowerShell to create an Azure SQL single database and configure a firewall rule and Monitor and scale an Azure SQL single database using PowerShell.
Manage Azure SQL servers, databases, and firewalls using the Azure CLI
To create and manage Azure SQL server, databases, and firewalls with the Azure CLI, use the following Azure CLI SQL Database commands. Use the Cloud Shell to run the CLI in your browser, or install it on macOS, Linux, or Windows. For creating and managing elastic pools, see Elastic pools.
|az sql db create||Creates a database|
|az sql db list||Lists all databases and data warehouses in a server, or all databases in an elastic pool|
|az sql db list-editions||Lists available service objectives and storage limits|
|az sql db list-usages||Returns database usages|
|az sql db show||Gets a database or data warehouse|
|az sql db update||Updates a database|
|az sql db delete||Removes a database|
|az group create||Creates a resource group|
|az sql server create||Creates a server|
|az sql server list||Lists servers|
|az sql server list-usages||Returns server usages|
|az sql server show||Gets a server|
|az sql server update||Updates a server|
|az sql server delete||Deletes a server|
|az sql server firewall-rule create||Creates a server firewall rule|
|az sql server firewall-rule list||Lists the firewall rules on a server|
|az sql server firewall-rule show||Shows the detail of a firewall rule|
|az sql server firewall-rule update||Updates a firewall rule|
|az sql server firewall-rule delete||Deletes a firewall rule|
For an Azure CLI quickstart, see Create an Azure SQL single database using the Azure CLI. For Azure CLI example scripts, see Use CLI to create an Azure SQL single database and configure a firewall rule and Use CLI to monitor and scale an Azure SQL single database.
Manage Azure SQL servers, databases, and firewalls using Transact-SQL
To create and manage Azure SQL server, databases, and firewalls with Transact-SQL, use the following T-SQL commands. You can issue these commands using the Azure portal, SQL Server Management Studio, Visual Studio Code, or any other program that can connect to an Azure SQL Database server and pass Transact-SQL commands. For managing elastic pools, see Elastic pools.
You cannot create or delete a server using Transact-SQL.
|CREATE DATABASE (Azure SQL Database)||Creates a new database. You must be connected to the master database to create a new database.|
|ALTER DATABASE (Azure SQL Database)||Modifies an Azure SQL database.|
|ALTER DATABASE (Azure SQL Data Warehouse)||Modifies an Azure SQL Data Warehouse.|
|DROP DATABASE (Transact-SQL)||Deletes a database.|
|sys.database_service_objectives (Azure SQL Database)||Returns the edition (service tier), service objective (pricing tier), and elastic pool name, if any, for an Azure SQL database or an Azure SQL Data Warehouse. If logged on to the master database in an Azure SQL Database server, returns information on all databases. For Azure SQL Data Warehouse, you must be connected to the master database.|
|sys.dm_db_resource_stats (Azure SQL Database)||Returns CPU, IO, and memory consumption for an Azure SQL Database database. One row exists for every 15 seconds, even if there is no activity in the database.|
|sys.resource_stats (Azure SQL Database)||Returns CPU usage and storage data for an Azure SQL Database. The data is collected and aggregated within five-minute intervals.|
|sys.database_connection_stats (Azure SQL Database)||Contains statistics for SQL Database database connectivity events, providing an overview of database connection successes and failures.|
|sys.event_log (Azure SQL Database)||Returns successful Azure SQL Database database connections, connection failures, and deadlocks. You can use this information to track or troubleshoot your database activity with SQL Database.|
|sp_set_firewall_rule (Azure SQL Database)||Creates or updates the server-level firewall settings for your SQL Database server. This stored procedure is only available in the master database to the server-level principal login. A server-level firewall rule can only be created using Transact-SQL after the first server-level firewall rule has been created by a user with Azure-level permissions|
|sys.firewall_rules (Azure SQL Database)||Returns information about the server-level firewall settings associated with your Microsoft Azure SQL Database.|
|sp_delete_firewall_rule (Azure SQL Database)||Removes server-level firewall settings from your SQL Database server. This stored procedure is only available in the master database to the server-level principal login.|
|sp_set_database_firewall_rule (Azure SQL Database)||Creates or updates the database-level firewall rules for your Azure SQL Database or SQL Data Warehouse. Database firewall rules can be configured for the master database, and for user databases on SQL Database. Database firewall rules are useful when using contained database users.|
|sys.database_firewall_rules (Azure SQL Database)||Returns information about the database-level firewall settings associated with your Microsoft Azure SQL Database.|
|sp_delete_database_firewall_rule (Azure SQL Database)||Removes database-level firewall setting from your Azure SQL Database or SQL Data Warehouse.|
For a quickstart using SQL Server Management Studio on Microsoft Windows, see Azure SQL Database: Use SQL Server Management Studio to connect and query data. For a quickstart using Visual Studio Code on the macOS, Linux, or Windows, see Azure SQL Database: Use Visual Studio Code to connect and query data.
Manage Azure SQL servers, databases, and firewalls using the REST API
To create and manage Azure SQL server, databases, and firewalls, use these REST API requests.
|Servers - Create or update||Creates or updates a new server.|
|Servers - Delete||Deletes a SQL server.|
|Servers - Get||Gets a server.|
|Servers - List||Returns a list of servers.|
|Servers - List by resource group||Returns a list of servers in a resource group.|
|Servers - Update||Updates an existing server.|
|Databases - Create or update||Creates a new database or updates an existing database.|
|Databases - Delete||Deletes a database.|
|Databases - Get||Gets a database.|
|Databases - List by elastic pool||Returns a list of databases in an elastic pool.|
|Databases - List by server||Returns a list of databases in a server.|
|Databases - Update||Updates an existing database.|
|Firewall rules - Create or update||Creates or updates a firewall rule.|
|Firewall rules - Delete||Deletes a firewall rule.|
|Firewall rules - Get||Gets a firewall rule.|
|Firewall rules - List by server||Returns a list of firewall rules.|