In the previous article Azure Arc, we learned in-depth about the Azure Arc. We learned how it enables the extension of numerous Azure Services to other services hosted on-premises or basically outside of Azure that may be in datacenters, or the multi-cloud environment or even on the edge. In this article, we’ll go through a step-by-step process to learn how we can manage the instances of our SQL Server through the Azure Arc-enabled servers.
Azure Arc
Azure Arc provides a platform that makes it extremely easy to manage environments thus simplifying the process of management and governance with consistent delivery of on-premises and multicloud. We’ll have a single control plane with Azure Arc which can extend Azure management and services anywhere from management of databases, virtual machines, and Kubernetes clusters. Developers and Architects can now gain the central visibility, operations, and compliance with Azure Arc. Moreover, building cloud native apps across platforms has never been this easier that can scale so easily. Furthermore, we can run Azure services anywhere with the Azure Arc.
How to Connect SQL Server to Azure Arc?
The first thing to realize is that we are connecting our SQL Server in our machine using the Azure Arc. Hence, it’s a prerequisite that at the least, one of the instances of SQL Server is installed in our machine. Next, the resource provider Microsoft Azure Arc Data must be registered.
How do we register the Microsoft Azure Arc Data resource provider?
Step 1
Firstly, search and visit the Subscriptions on your Azure Portal.
Step 2
Select the Subscription you are using.
Step 3
You’ll now be taken to the Subscription Detail Page. On the left-hand side, Under the Settings Menu you’ll see the Resource Provider Section. Select that.
Step 4
Now, search for Microsoft.AzureArcData and Select the Register.
Once, it's registered, you can see the Green Tick on the Status.
Now, the AzureArcData has been ready and we are set to go.
How do we initiate the connection from the Azure?
We can initiate the connection of the SQL Server on the machine with Azure Arc in numerous ways from using the Azure Portal, PowerShell, and Azure CLI. Here, we’ll learn the Azure Portal way.
Step 1
From the Menu bar on the Azure Portal Homepage, Select the Resource Groups tab.
Step 2
Choose the resource group where the Server-Azure Arc resource is contained.
Step 3
Click on Access Control (IAM)
Step 4
Click on Add and then choose Add role assignment.
Next, as per Role, Assign Access and Select choose accordingly.
Select Azure Connected SQL Server Onboarding for Role.
Select User, Group or Service Principal for Assign Access.
Search and select Server – Azure Arc for Select.
Next, Click on Save.
With this, the connection between our machine and Azure is built.
How do we initialize connection from our Target Machine?
We’ll be using the onboarding script from Azure to perform this task. Hence, we must obtain this from the Azure itself.
Step 1
Visit the Azure Portal. You’ll be welcomed to the Home Page.
Step 2
Search from SQL Server – Azure Arc and Select it.
Step 3
Click on Create SQL Server – Azure Arc.
You’ll be showcased with the Pre-requisites which we have already fulfilled.
Step 4
Next, we fill in the Server Details.
Select the Subscription and Resource Group, Region, and Operating System to work on.
Step 5
Now, Click on Run Script.
You’ll be showcased with the Downloadable script and the process to run the script in our machine.
Click on Download to obtain the file.
Connecting the SQL Server Instance to Azure Arc
With all other processes performed, all we need to do now is connect the SQL Server in our machine to Azure Arc. This is performed through different processes depending upon the operating system in our machine.
For Windows
We launch the powershell with admin accessibility. Next, we sign in to our Powershell using the Azure credentials where the Azure Arc is being connected.
Finally, we execute the downloaded script using the following command.
& '.\RegisterSqlServerArc.ps1'
For Linux
We sign in using our Azure credential and in the terminal gratd access with the execution permission with the command below to the script we downloaded from Azure and then execute it.
sudo chmod +x ./RegisterSqlServerArc.sh
./RegisterSqlServerArc.sh
With this, we have now connected our SQL Server and Azure through the Azure Arc. This process enables organization to connect with their on-premises machines or edge and even use multi-cloud architecture with Azure services.
Conclusion
Thus, in this article, we went through a step-by-step process to connect SQL Server to Azure Arc. Firstly, we register Azure Arc Data in resource provider followed by initiating the connection of the SQL Server on our machine to Azure Arc. Once this is done, we imitated our connection to our target machine and finally was successful to connect our SQL Server to Azure Arc.