Connect your SQL Server to Azure Arc
Beginning with SQL Server 2022 (16.x) you connect a new SQL Server instance to Azure Arc when you're installing it on Windows Operating System. See Install SQL Server 2022.
You can connect your existing SQL Server instance to Azure Arc by following these steps.
Prerequisites
You need an Azure account with an active subscription. Create one for free.
The Microsoft.AzureArcData and Microsoft.HybridCompute resource providers have been registered.
The user onboarding Arc-enabled SQL Server resources must have the following permissions:
Microsoft.AzureArcData/sqlServerInstances/read
Microsoft.AzureArcData/sqlServerInstances/write
Note
SQL Server on Azure Arc-enabled servers does not support SQL Server Failover Cluster Instances.
To register the resource providers, use one of the methods below:
- Select Subscriptions.
- Choose your subscription.
- Under Settings, select Resource providers.
- Search for
Microsoft.AzureArcDataandMicrosoft.HybridComputeand select Register.
When the machine is already connected to an Arc-enabled Server
If the machine with SQL Server is already connected to Azure Arc, you can connect the SQL Server instances by installing Azure extension for SQL Server. The SQL Server extension for Azure Arc Server can be found in the extension manager as SQL Server Extension - Azure Arc. Once installed, the Azure extension for SQL Server will recognize all the installed SQL Server instances and connect them with Azure Arc. The extension will run continuously to detect changes in the SQL Server configuration. For example, if a new SQL Server instance is installed on the machine, it will be automatically registered with Azure Arc. See virtual machine extension management for instructions on how to install and uninstall extensions to Azure connected machine agent using the Azure portal, Azure PowerShell or Azure CLI.
Important
- The Managed System Identity used by the Azure connected machine agent must have the Azure Connected SQL Server Onboarding role at the resource group level.
- The Azure resource with type
SQL Server - Azure Arcrepresenting the SQL Server instance installed on the machine uses the same region and resource group as the Azure resources for Arc-enabled servers.
To install the Azure extension for SQL Server, use the following steps:
- Open the Azure Arc > Servers resource.
- Search for the connected server with the SQL Server instance that you want to connect to Azure.
- Under Extensions, select + Add.
- Select
Azure extension for SQL Serverand select Next. - Specify the SQL Server instance(s) you want to exclude from registering (if you have multiple instances installed on the server) and select Review + Create.
- Select Create.
Note
The specified resource group must match the resource group where the corresponding connected server is registered. Otherwise, the command will fail. an
When the machine isn't connected to an Arc-enabled Server
If the server that runs your SQL Server instance isn't yet connected to Azure, you can initiate the connection from the target machine using the onboarding script. This script will connect the server to Azure and install the Azure extension for SQL Server.
Generate an onboarding script for SQL Server
Go to Azure Arc > SQL Server and select + Add
Select Connect SQL Server to Azure Arc
Review the prerequisites and select Next: Server details
Select the subscription, resource group, Azure region, and host operating system. If necessary, specify the proxy your network uses to connect to the Internet.
Important
If the machine hosting the SQL Server instance is already connected to Azure Arc, make sure to select the same resource group that contains the corresponding Server - Azure Arc resource.
Select Tags to optionally add tags to the resource for your SQL Server instance.
Select Run script to generate the onboarding script. Screenshot of
Select Download to download the script to your machine.
Connect SQL Server instances to Azure Arc
In this step, you'll take the script you downloaded from the Azure portal and execute it on the target machine. The script installs Azure extension for SQL Server. If the machine itself doesn't have the Azure connected machine agent installed, the script will install it first, then install the Azure extension for SQL Server. Azure connected machine agent will register the connected server as an Azure resource of type Server - Azure Arc, and Azure extension for SQL Server will connect the SQL Server instances as Azure resources of type SQL Server - Azure Arc.
Important
Make sure to execute the script using an account that meets the minimum permission requirements described in prerequisites.
Launch an admin instance of powershell.exe and sign in to your PowerShell module with your Azure credentials. Follow the sign-in instructions.
Execute the downloaded script.
& '.\RegisterSqlServerArc.ps1'Note
If you have yet to previously install the Az PowerShell module and see issues the first time you run it, follow the instructions in the script and rerun it.
Deploy SQL Server extension from AzureExtensionForSQLServer.msi
Alternatively, you can also onboard your SQL Servers to Azure Arc by directly using AzureExtensionForSQLServer.msi. This method helps you integrate onboarding SQL Servers to Arc with any existing deployment automation tools and services.
Download AzureExtensionForSQLServer.msi from the link.
Double-select on AzureExtensionForSQLServer.msi. This installs the necessary packages for onboarding SQL Servers to Azure Arc.
Open PowerShell console in admin mode and execute the following commands.
If you use Azure Active Directory service principal to authenticate, execute the command below on the target SQL Server.
'& "$env:ProgramW6432\AzureExtensionForSQLServer\AzureExtensionForSQLServer.exe" --subId <subscriptionid> --resourceGroup <resourceGroupName> --location <AzureLocation> --tenantid <TenantId> --service-principal-app-id <servicePrincipalAppId> --service-principal-secret <servicePrincipalSecret> --proxy <proxy> --tags ""'Otherwise, execute the command below on the target SQL Server.
'& "$env:ProgramW6432\AzureExtensionForSQLServer\AzureExtensionForSQLServer.exe" --subId <subscriptionid>--resourceGroup <resourceGroupName> --location <AzureLocation> --tenantid <TenantId> --proxy <proxy> --tags ""'
Important
Microsoft Azure Arc-enabled SQL Server is licensed to you as part of your or your company's subscription license for Microsoft Azure Services. You may only use the software with Microsoft Azure Services and are subject to the terms and conditions of the agreement under which you obtained Microsoft Azure Services. You may not use the software if you do not have an active subscription license for Microsoft Azure Services.
Microsoft Azure Legal Information: Microsoft Azure Legal Information and Microsoft Privacy Statement
Validate your Arc-enabled SQL Server resources
Go to Azure Arc > SQL Server and open the newly registered Arc-enabled SQL Server resource to validate.
Delete your Arc-enabled SQL Server resource
To delete your Arc-enabled SQL Server resource, go to Azure Arc > SQL Server, open the Arc-enabled SQL Server resource for that instance, and select the Delete button.
Important
Because multiple SQL Server instances could be installed on the same machine, the Delete button will not uninstall the Azure extension for SQL Server on that machine. To uninstall it, follow the uninstall extension steps.
Restore a deleted Arc-enabled SQL Server resource
If you accidentally deleted your Arc-enabled SQL Server resource, you can restore it with the following steps.
If you also uninstalled the SQL Server extension by mistake, reinstall it. Select the correct version for your OS.
az connectedmachine extension create --machine-name "{your machine name}" --location "{azure region}" --name "WindowsAgent.SqlServer" --resource-group "{your resource group name}" --type "{OS}Agent.SqlServer" --publisher "Microsoft.AzureData" --settings '{\"SqlManagement\":{\"IsEnabled\":true}, \"excludedSqlInstances\":[]}'Important
The location property must match the location of the Arc-enabled SQL Server resource for the server specified by the
--machine-nameparameter.Check to make sure your instance is in the exclusion list (see the value of the excludedSqlInstances property).
az connectedmachine extension show --machine-name "{your machine name}" --resource-group "{your resource group name}" -n WindowsAgent.SqlServerMake sure to remove your instance from the exclusion list and update the extension settings.
az connectedmachine extension create --machine-name "{your machine name}" --location "{azure region}" --name "WindowsAgent.SqlServer" --resource-group "{your resource group name}" --type "WindowsAgent.SqlServer" --publisher "Microsoft.AzureData" --settings '{\"SqlManagement\":{\"IsEnabled\":true}, \"excludedSqlInstances\":[\"{named instance 1}\",\"{named instance 3}}\"]}'
The instance is restored after the next sync with the agent. For information on managing vm extensions using Portal or PowerShell, see virtual machine extension management.
Next steps
Feedback
Submit and view feedback for