Issue

If you are trying stretch database for the first time and you could see the below error.

If you carefully read the above error message the can fix the issue easily.

It says that “The subscription must be registered to use namespace “Microsoft.Sql”.”

Solution:

This should be fixed in Azure Portal. Usually, this error message will appear when you have a fresh azure subscription and not having any SQL server related resources on it.

Check the namespace in Azure Portal.

Follow the below steps,

Step 1: Click the Subscriptions


Step 2: Choose the subscription -> Resource Providers -> Microsoft.Sql. It will be “Unregistered” Status.



This can be fixed in two ways,

Way 1: Manual

Click the Register and it will be registered. 


Way 2:

Create SQL resources in Azure portal. It will register the resource provider “Microsoft.Sql” automatically.

SQL resources can be SQL Server (Logical Server) & Azure SQL Databases, etc.