The Wayback Machine - https://web.archive.org/web/20240927190658/https://www.geeksforgeeks.org/microsoft-azure-configure-azure-sql-with-azure-cli/
Open In App

Microsoft Azure – Configure Azure SQL with Azure CLI

Last Updated : 30 Mar, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

 In this article, we’re going to take a closer look at how you can configure something like connectivity using the Azure CLI. What we have here is we are in Azure Data Studio and similar to the SQL notebook we are actually using a PowerShell notebook. That just means all our code cells are going to run PowerShell and we are just connecting to localhost. 

Now one thing to note is we can use the Azure CLI or these az commands to basically do various tasks with all our Azure resources, not necessarily just Azure SQL Database or Azure SQL Managed Instance. We can also use this in the Cloud Shell. Or we can use the Azure CLI and something like PowerShell like we’re doing here. 

In this example, we’re going to walk through how you can set up and configure your connectivity to Azure SQL and a brief look at what that impact is on the performance. 

 First what we are doing is we are using the below command to get the current connection policy to our Azure SQL Database logical server. 

az sql server conn-policy show

What you see is we’ve got the Default response. This default response means that for services within Azure, we are going to use the redirect method, but for services outside of Azure, we are going to use the proxy method. 

Now for this little test that we’re going to do, we’re going to update the connection policy to the proxy. So basically we want everything to go to the gateway and then go to the database. Here we used AZ SQL server connection policy update and then specify the proxy policy type and then we are just printing out that connection type to confirm that it worked. 

Now that it worked, we can do an unofficial test to see how it affects performance. So in SSMS, we are just going to create a new query where we select all from SalesLT.Product and we are going to include client statistics. Then we are going to run this 10 times and then we can get a good average to see what our network latency is. 

Now that it’s run, we can go into “Client statistics” and down at the bottom, we can see the wait time on server replies. Now if we scroll all the way to the right, we are going to see that on average the wait time on server replies is about 192.78 milliseconds.

Basically what this means is it can be an indication of the network latency that we are seeing.

Now if we switch back to Azure Data Studio and we remember that number of 50 milliseconds, what we are going to do is update the policy to redirect. Remember in redirect, we’re going to go to the gateway the first time, but then we’re going to go directly to the database after that. So what I’ve done is use the same command to just to update the connection policy to redirect and then we are just printing out the connection type to confirm that worked.

Again, now we’re going to do the same exact thing in SSMS, except we are going to do it with redirect and see if there’s a change. So we’ll include client statistics and run this about 10 times. Now that that’s done, we can check the client statistics again look at the wait time on server replies, which is an indication of latency, and what we are seeing is about 125 milliseconds for wait time on server replies.

With a redirect, we were able to get 67 milliseconds of network latency, which is significantly less than the 192 milliseconds that we saw for the proxy connection. Now, this is going to change on your network and your internet connection and a bunch of other things but what you’re going to see is a reduction in that latency with the redirect method. So in this demo, you saw how to use the Azure CLI to configure various things, in this case, SQL connectivity. 


Previous Article
Next Article

Similar Reads

Microsoft Azure - Azure CLI Commands to Manage Azure VMs
Azure Command-line interface is used to manage or to create Azure resources. By using the simple AZ CLI command we can manage Azure VM quickly and at a Scale. Let's get started by using a few important Azure CLI commands to manage Azure Virtual Machines. 1. Start a Specific Stopped VM in a Select Resource Group Use the below command to start a spec
2 min read
Microsoft Azure - Install Azure Command Line Interface (Azure CLI)
Azure CLI is a very powerful tool that can be used to automate tasks, create, update, manage or delete azure resources or to troubleshoot problems with az module cmdlets. By installing az modules on your system or on your development system you and your development team can easily create, update or manage Azure AD and Azure resources such as manage
4 min read
Microsoft Azure - Configure Auditing for Azure SQL Database
In this article, we will look into the process of configuring auditing for the Azure SQL Database. Follow the below steps to configure auditing for Azure SQL Database: Step 1: Here in the portal, we're looking at the Azure SQL Database, and down on the left under Security, we can select the Auditing tab. Step 2: Now, this is where we would go if we
2 min read
Microsoft Azure - Configure Azure SQL
Pre-requisite: Azure VM Azure SQL Database is a cloud-based PaaS database service that is completely managed and extremely scalable. When you need to establish a new application in the cloud, this service includes the essential database-level capabilities of an on-premises SQL Server. The Azure SQL Database can be used as a single database or as pa
2 min read
Microsoft Azure - Using Table Parameter in Azure CLI
In this article, you'll learn how to use the Table Parameter to change the format of the output when you're issuing commands with the Azure CLI. When you're working with version 2.0 of the Azure CLI, the results from the commands that you're on are typically returned to you in the JSON format. So, for instance, if we want to search for our resource
2 min read
Microsoft Azure - Create App Service Plan For Linux (Azure CLI)
An app service plan is a subscription model for hosting apps on Azure. It allows you to host multiple apps on a single server without having to pay for each app separately. In this article, we will show you how to deploy an Azure App Service Plan for Linux service type using Azure CLI (Command Line Interface) from Azure Portal in simple easy steps.
2 min read
Microsoft Azure - Building Your Own Azure CLI Extensions
Pre-requisite: AZURE, Python wheel, PIP Extensions for the Azure CLI are really useful. This Azure Tip has information on them. You may choose extensions from this list, which is also accessible when you run the Azure CLI command az extension list-available —output table.Steps To Build Azure CLI ExtensionsStep 1: The first thing we'll do is make a
3 min read
Microsoft Azure - Configure Diagnostic Settings For Azure Subscription
Enabling the Diagnostics Setting for Azure Subscription will help in getting the Activity Logs that were performed on Azure Subscription. It will collect the activity logs of Operation Name, Status, Time, Subscription, Event initiated by, and much more in-depth. Prerequisites:Active Azure SubscriptionLog Analytics WorkspaceThe Following Roles are r
2 min read
Microsoft Azure - Create App Service Plan for Windows Service using CLI
Pre-requisite:- Azure An App Service Plan is a subscription model for hosting apps on Azure. It allows you to host multiple apps on a single server without paying for each app separately. This article will show you how to deploy an Azure App Service Plan with Windows service type using Azure CLI (Command Line Interface) from Azure Portal using Clou
2 min read
Microsoft Azure - Setup Budget Alert and Configure Email Notification
Budgets Alert is a Cost Management tool in Microsoft Azure that helps you to get notified about your active azure subscription spending to proactively manage the costs of your azure resources which are being used. With these Azure budget alerts, you can track and monitor spending. This also helps to analyze the cost and to manage your budget to sav
2 min read
How to Configure Azure Activity "Administrative" Logs on Azure Subscription using PowerShell?
Azure Activity "Administrative" logs are a type of activity log that record events that occur in your Azure subscription. By enabling and configuring the Azure Activity "Administrative" logs will collect and store logs in your specified log analytics workspace (this is your log destination). Administrative logs help you to view and analyze the logs
3 min read
Microsoft Azure- Backing Up, Restoring, and Cloning Microsoft Azure App Services
Microsoft is well known for developing relevant software which are using in today's time of technology to conquer the demand of users and developers to build up applications. In sequence of it Microsoft introduces Azure well known as Microsoft Azure to make quality applications. In this article, we will discuss Backing up, restoring and cloning Mic
8 min read
Microsoft Azure -Create a User in Microsoft Entra ID from Azure Portal
A user in Microsoft Entra ID is an individual who can get access to Azure identity. This Microsoft Entra ID identity can be used to access applications and resources that are protected within the organization or project. Users can be created manually or automatically, and they can be assigned to groups and roles to control their access permissions.
3 min read
Microsoft Azure- Disk Storage in Microsoft Azure
Azure Disk Storage is the only shared cloud block storage that supports both Windows and Linux-based clustered or high-availability applications via Azure shared disks. There are two types of Disks in Azure : Managed Disks Unmanaged Disks.Managed DisksSimplest optionLower management overhead as Azure manages the storage accounts.Only LRS replicatio
6 min read
Microsoft Azure - Get Azure VM Properties using Azure PowerShell
The purpose of using the Azure PowerShell Commands is to quickly analyze the overall properties of VM/VMs at once the filtering the with select and where conditions. To find the properties of an Azure VM, you can perform the following commands in Azure Cloud Shell to get the details. Command: Get-AzVM Output: 1. Get all properties of an Azure Virtu
2 min read
Microsoft Azure - RDP to Azure Virtual Machines using Azure Bastion
In this article, we will learn how to do RDP(Remote Desktop Protocol) / SSH(Secure Shell) Connection to an Azure VM using Azure Bastion. First, let's discuss Azure Bastion. The Azure Bastion service is a fully platform-managed PaaS service that you provision inside your virtual network. It provides secure and seamless RDP/SSH connectivity to your v
3 min read
Microsoft Azure - Get CPU Utilization Data of a Azure VM in Azure Portal
Azure Virtual Machines (VM) is one of several types of on-demand, scalable computing resources that Azure offers. In this article, we will look into the process of getting the CPU Utilization data of an Azure VM in Azure Portal. Implementation: Follow the steps to get the CPU Utilization of an Azure VM in Azure Portal: Step 1: Log in to your Azure
2 min read
Microsoft Azure - Archive Azure VM to Azure Storage Account
In this article, we will be implementing a solution to archive a select azure VM snapshot to a select storage account for archiving using azure cloud shell. For implementation, we will be using Azure CLI commands. Prerequisite:VM SnapshotA storage account is neededUser needs "Storage Blob Contributor Data" IAM Role Access on Archiving Storage Accou
2 min read
Microsoft Azure - Check Status of Azure VM using Azure PowerShell
The following Azure PowerShell command helps you to find the Azure VM Config and properties details of Os Name, Os Version, Hyper V Generation, Disks properties, Extensions properties of Type Handler Version, Status and Message, VM Agents properties of Type Handler Version, Status and Message and also VM Power Status Codes, Messages, Plugins, Time
3 min read
Microsoft Azure - Azure VM Disk Space in Percentage using Azure KQL
Here we'll be using the Azure Insights Metric Query to find the free disk space in percentage using KQL. The purpose of this query is to find disk drive free space of all the Azure VMs without logging into every server. You can Run the following KQL log Queries in Azure Monitor or Azure VM Logs or Log Analytics Workspace. Note: VM Insights Agent sh
1 min read
Microsoft Azure - Enable Azure Monitor VM Insights Agent For Azure VM
Azure Monitor VM Insights Agent enables you to get more visibility into the health and performance of your Azure VM. Here we'll see how we can enable Azure Monitor VM Insights to monitor the health, performance, and dependencies of azure virtual machines. Implementation: Follow the below steps to enable Azure Monitor VM insights agents for an Azure
2 min read
Microsoft Azure - Manage Azure VMs using Azure PowerShell Commands
Here we are using Azure PS Commands to manage azure resources from Azure Cloud Shell or by using Windows PowerShell. By using the simple AZ PS command we can manage Azure VM Quicks without any efforts of navigating in Azure Portal and at Scale. Let's get started by using the major Azure PS commands to manage Azure Virtual Machine. 1. Start a Specif
2 min read
Microsoft Azure - Query Azure Storage Logs in Azure Monitor Log Analytics
Pre-requisite:- Azure Log Analytics is a tool offered by Azure, which is used to edit and run log queries against data in the Azure Monitor Logs store and helps interactively analyze their results. One can easily use Log Analytics queries to retrieve records that match particular criteria, identify trends, analyze patterns, and provide various insi
5 min read
Microsoft Azure - Advanced Threat Protection for Azure SQL Database
In this article, we will look into how to configure Advanced Threat Protection in Azure SQL Database. Advanced Threat Protection is a feature of Azure SQL Database that detects security threats and anomalies and lets you know about them so that you can act. Follow the below steps to configure it: Step 1: Here we already have an existing Azure SQL D
2 min read
Microsoft Azure - Introduction to Azure SQL Database
Azure SQL Database is a database built for modern Cloud applications. Developers and clients opt for Azure SQL for one or more of the below-mentioned reasons: If they want to build multi-tenanted software as a service type of application, elastic pools are a great option for the same.If they have a database and they don't want to have to choose bet
3 min read
Microsoft Azure - PaaS vs. IaaS in Azure SQL
SQL Server on an Azure Virtual Machine is known as IaaS or Infrastructure as a Service. As we move towards Azure SQL Database and Azure SQL Managed Instance, we moved towards the territory of Platform as a Service or PaaS type of offerings. In this article, we will break down the differences between IaaS and PaaS. The one big difference before we g
4 min read
Microsoft Azure - Introduction to Azure SQL
This article aims to explain what is Azure SQL and how to translate your existing SQL Server expertise to Azure SQL. This is going to include Azure SQL database and Azure SQL Managed Instance. It also aims to explain the foundational knowledge of what to use when, as well as how to configure, monitor, and troubleshoot. The key feature of SQL Server
5 min read
Microsoft Azure - Azure SQL Managed Instance Deployment Options
In this article, we will take a deeper look at the differences between Azure SQL Managed Instance and Azure SQL Database. When you're going to deploy a Managed Instance, you're first going to have some choices to make. You can deploy a single instance, which is like a single instance of SQL Server, get these capabilities of your surface area, of yo
3 min read
Microsoft Azure - Management Interfaces for Azure SQL
In this article, we will look into the management interfaces for Azure SQL. There are different ways to interact with Azure SQL. One of those ways is the Azure portal, and the below image shows the Azure SQL unified experience where Azure tried to ease the process of decision-making for users(ie, what to use when) into the portal itself. Azure make
2 min read
Microsoft Azure - Azure SQL Database Deployment Options
Azure SQL Database is a database built for modern Cloud applications. Now coming back to the eccentric concepts for which consider If you have ever worked with Azure SQL Database, you must have come across terms such as "single database" or "Elastic scaling" and so on. There is an increasing trend of building applications in the cloud today. For an
5 min read