AzureTipsAndTricks/blog/tip345.md

7.2 KiB

type title excerpt tags share date
post Tip 345 - How to enable Azure SQL managed instance in Azure Arc - Part 3 Learn how to enable Azure SQL managed instance in Azure Arc - Part 3
Management and Governance
Databases
true 2021-12-7 08:00:00

::: tip

🔥 Download the FREE Azure Developer Guide eBook here.

💡 Learn more : What is Azure SQL Managed Instance?.

📺 Watch the video : How to enable Azure SQL managed instance in Azure Arc - Part 3.

:::

How to enable Azure SQL managed instance in Azure Arc - Part 3

Full control over a PaaS-enabled SQL Server

Azure SQL Managed Instance allows you to run SQL Server in your control, enabling you to adhere to your security and policy requirements. It also provides PaaS features like automatic patching and version updates, automated backups and high availability, which make management easy.

Azure Arc-enabled SQL Managed Instance allows you to run your SQL Managed instance anywhere. All you need is a an Azure Arc-enabled Kubernetes cluster with a data controller in it.

In this third part of the three-part Azure Arc series, we'll use the Arc-enabled Kubernetes cluster to create a data controller and host a SQL Managed Instance in it.

Prerequisites

If you want to follow along, you'll need the following:

  • An Azure subscription (If you don't have an Azure subscription, create a free account before you begin)
  • You need to have an Arc-enabled server, with an Arc-enabled Kubernetes cluster. You can follow part 1 and part 2 of this series of posts to get started.

Create an Azure Arc-enabled SQL Managed Instance

Before we can deploy data services, like a SQL Managed Instance, we need to create an Azure Arc data controller in the Arc-enabled Kubernetes.

  1. First we need to create an Azure Service Principal that the data controller uses to send metrics to Azure Monitor. Run the script below in the Azure Cloud Shell to create the service principal, and replace {ServicePrincipalName}, {SubscriptionId}, and {resourcegroup}. Make sure to save the details of the Service Principal when it is created
az ad sp create-for-rbac --name {ServicePrincipalName} --role Contributor --scopes /subscriptions/{SubscriptionId}/resourceGroups/{resourcegroup}
  1. Now assign a role to the service principal. Replace {appId}, {SubscriptionID}, and {resourcegroup}.
az role assignment create --assignee {appId} --role 'Monitoring Metrics Publisher' --scope subscriptions/{SubscriptionID}/resourceGroups/{resourcegroup}
  1. Next, go to the Azure portal
  2. Search for "Azure Arc" in the search box and click on the result. You will now see the Azure Arc overview blade
  3. Navigate to the Kubernetes clusters menu
  4. You'll see the connected Kubernetes cluster. Click on it
  5. Click on the Extensions menu
  6. Click Add
  7. Select Azure Arc data controller, and click Create. We need this to enable Azure Arc data services
  8. Fill in a name for the data controller
  9. Create a new Custom location by filling in a Name and Namespace. We'll use this later to deploy the SQL Managed Instance
  10. Select the Kubernetes configuration template that best resembles your Kubernetes cluster
  11. Pick the network Service Type
  12. Fill in a data controller Login and Password. You need these when you want to log into the data controller from other applications, like Azure Data Studio
  13. Fill in the details of the Service Principal that we created earlier
  14. Click Next: Additional Settings

(Create Azure Arc data controller)

  1. Uncheck the "Enable logs upload" setting
  2. Click Next: Tags
  3. Select Next: Review + Create, and then Create

After creating the data controller, you'll find it in the Azure Arc resource in the Azure portal. And in the Custom locations menu, you'll find the location it created.

(Azure Arc Custom location)

Next, we can create an Arc-enabled SQL Managed Instance.

  1. In the Arc resource in the Azure portal, navigate to the SQL Managed Instances menu
  2. Click Create
  3. Select the Resource group that contains the Arc-enabled Kubernetes cluster
  4. Pick the Custom location that the data controller created
  5. For Service type, select LoadBalancer
  6. Fill in the credentials for the Managed Instance with the Login and Password. You'll need these to log into the SQL Managed Instance
  7. Click Review + Create and then Create

(Create an Arc-enabled SQL Managed Instance)

It can take a few minutes to create the Managed Instance. When it's done, you can find it through the Azure Arc resource in the Azure portal. Or in the list of SQL Managed Instances, where it looks and behaves just like other SQL Managed Instances. The only difference is that it runs on an Arc-enabled Kubernetes cluster that runs on my local machine.

(The Arc-enabled SQL Managed Instance in the Azure portal)

Conclusion

Azure Arc enables you to run managed Azure services anywhere, including data services like Azure SQL Managed Instance, on an Arc-enabled Kubernetes cluster. Go and check it out!