How to manage Azure using Windows PowerShell

Introduction

#PowerShell, #Bash and #CLI, and the most common language now for how to manage #Azure are very helpful when you need to automate the tasks did you imagine that you can know provision new VM or new SQL on Azure using your mobile though azure mobile app with Powershell. πŸ’₯β›ˆ

If you asked me what is the best? I will be told you nothing all of them are very powerful language and choosing which one of them depends on your past experiences If you are coming from background windows so the PowerShell is the most compatibles with you and if you are coming from Linux background Bash will be the most compatible with you.

How I prepare my local PC to be able to manage azure using theses language?

This is our post of today, all of us know that we have the availability to write PowerShell or Bach code from Azure portal itself😲 . But if we need to manage the portal from our PC, we need to install some tools and import some modules, at the end of the post you will find most of the tools and requirements and advanced tools you can use it on your local PC or on-Premises server to manage Azure.🦾

Note🚦: If you didn’t used Cloud shell before on Azure portal, when you start it portal will ask you to create Storage account for more information check this postStep by Step How to Enable Azure Cloud Shell in Microsoft Azure“πŸš€

Azure Cloud Shell

AS i explained above ⬆ How we can enable cloud shell on azure portal i need to share with you YouTube channel you can learn from it more information about how to use cloud shell

How to Enable Azure AZ module

  • Open PowerShell on your Local PC AS administrator
  • Install Az module using this first command
  • Check the Az module after installation using last two command
Install-Module -Name Az -AllowClobber -Force -Verbose
Get-InstalledModule -Name Az -AllVersions | select Name,Version
Get-Module -ListAvailable *Az*

Introducing the new Azure PowerShell Az module

Install Azure PowerShell

Enable Azure CLI on Windows PowerShell

  • Download and install MSI installer using this link (Install Azure CLI on Windows)
  • Open Windows PowerShell As Administrator and Write Az
  • If you need to enable the interactive mode only write Az interactive

Get started with Azure CLI

Azure CLI Interactive Mode

Enable Azure Module

  • Open Windows PowerShell As Administrator
  • Execute below two PowerShell Command
Install-Module Azure -AllowClobber -Force -Verbose
Import-Module Azure -Force -Verbose

Enable AzureRM Module

  • Open Windows PowerShell As Administrator
  • Execute below two PowerShell Command
  • Check the Module after installation using second command
Install-Module AzureRM -AllowClobber -force -Verbose
Get-Module -ListAvailable *Azure*

Check Azure Module Versions

Get-InstalledModule Azure -AllVersions | Select-Object Name,Version,Path
Get-InstalledModule AzureRM -AllVersions | Select-Object Name,Version,Path
Get-InstalledModule Az -AllVersions | Select-Object Name,Version,Path
Check Azure Module

Azure Support

In case if you have any issue on these steps you can contact me or leave your comment by your issue and i will do my best to support you otherwise you can communicate with Microsoft support team they are very supportive and they will fix to you all of your issues

Most used tools for Managing azure from on-Premises

Tool NameSite Link
Azure Portalhttps://portal.azure.com/
Azure accounthttps://account.azure.com/Profile
.Net Framework 4.7https://docs.microsoft.com/en-us/dotnet/framework/install/
Windows Powershellhttps://github.com/powershell/powershell
Azure Studiohttps://docs.microsoft.com/en-us/sql/azure-data-studio/what-is?view=sql-server-ver15
Install Azure CLIhttps://docs.microsoft.com/en-us/cli/azure/install-azure-cli-windows?view=azure-cli-latest
Install Azure PowerShell Modulehttps://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-3.6.1&viewFallbackFrom=azps-1.2.0#install-the-azure-powershell-module
Install AzCopy Command-Line Tool for Azure Storagehttps://aka.ms/downloadazcopy
Install Azure Storage Emulatorhttps://go.microsoft.com/fwlink/?LinkId=717179&clcid=0x409
Azure Storage Explorehttps://azure.microsoft.com/en-us/features/storage-explorer
Install PowerShell Module Manger 2020https://www.sapien.com/software/powershell_modulemanager

Conclusion

It is very important now to know how to use these languages or at least one of them to be able to automate and custom your azure tasks from your azure portal, PC or even your mobile phone using an azure mobile application.

Backup Tips on SQL Azure

Based on my Study i will list some tips and notes related to the backup on SQL Azure, I will be Happy if you ٍshared your knowledge, experiences and your review in the comment.

SQL AZURE BACKUP

  • Backup Concept: Backup on SQL Azure DB is taken Automatically and the first backup is taken after the DB Provisioning, however, you can’t download this backup or doing a manual restore from it.
  • Backup Storage: Microsoft support us with free storage based on the DB size on Services Tier selected, and it gives us 2 MAX size of the DB size, Azure SQL Database backups are stored in geo-replicated blob storage (RA-GRS storage type)
  • Reaching Backup Storage Limit: at this time, we have two solutions (1) Reduce the retention period by Contacting the Support team and this time you will not pay an extra charge (2) Pay for an extra backup build at the stander Read Access Geographically redundant storage rate 
  • Archiving data:In case if we have data archiving, we have two solutions to archive it on azure (1) Export the DB as BACPAC file and save it on Azure blob storage (2) Use Long-Term-backup-retention (LTR)to the Azure backup vault and you can keep it to 10 years
  • Backup retention period: It is depending on services tier model (basic = 7 days, stander and premium = 35 days) however we have β€œLong Term backup retention” for 10 years to an azure backup vault
  • : this means the Azure replicated the backup cross regions, and in case of the region down you can restore the backup in another region, but this feature replicated the FULL and DIFF backup only. This meaning the RPO will be one hour because the DIFF taking every one Hour
  • Azure backup RTO and RPO: Microsoft Support Point in Time Recovery with 12 Hours as RTO and 5 minutes as RPO for the in-Region backups
  • Disaster: If you delete the DB you can restore it on the retention period time based on your Services tier For Example if your DB in basic service tier and you delete the DB you can restore the DB in 7 days after this you will not find your backup , If you delete the server all backup will be deleted and you will not have any option to restore your DB
  • Manual backup:  There is no Manual backup on Azure SQL Database but we can take backup from the data and Structure database using another way called BACPAC and we can do Export for the BACPAC file on azure storage account using Azure portal, PowerShell and we can do the same to on-Premises system using sqlpackage.exe , also we can export BACPAC file using SSMS SQL Server Management studio
  • When using the Azure Backup service to store backups of virtual machines, which container is required? Recovery Services Vault
  • What is Azure Backup Explorer Today, we are pleased to share the preview of Backup Explorer. Backup Explorer is a built-in Azure Monitor Workbook enabling you to have a single pane of glass for performing real-time monitoring across your entire backup estate on Azure. It comes completely out-of-the-box, with no additional costs, via native integration with : T Azure Resource Graph and Azure Workbooks. https://azure.microsoft.com/en-us/blog/backup-explorer-now-available-in-preview/?WT.mc_id=linkedin-social-thmaure

What are the benefits from Azure backup Explorer

  •  At-scale views: With Backup Explorer, monitoring is no longer limited to a Recovery Services vault. You can get an aggregated view of your entire estate from a backup perspective. This includes not only information on your backup items, but also resources that are not configured for backup
  • Deep drill-downs β€“ You can quickly switch between aggregated views and highly granular data for any of your backup-related artifacts, be it backup items, jobs, alerts or policies
  • Quick troubleshooting and actionability β€“ The at-scale views and deep drill-downs are designed to aid you in getting to the root cause of a backup-related issue. Once you identify an issue, you can act on it by seamlessly navigating to the backup item or the Azure resource, right from Backup Explorer.

Why I should upgrade to SQL Server 2019 even if I will not use the big features on it (Big Data Cluster)

AS all of us know SQL Server 2019 is the latest SQL Server version and it come up with very sophisticated and impressed enhancements.

The most interested features is Big Data Clusters and How SQL Server now are able to integrated with other database and open sources and How SQL Server are now working and supporting all of the new technologies in the market like ( Spark, Hadoop, HDFS, Python, Docker, Kubernetes, machine learning, Kafka, NoSQL  ..etc)

shall this means if i will not use all of this features no need to upgrade to SQL Server 2019 ?

My answer NOOOOO SQL Server 2019 come up with many other features that’s Urges to upgrade to it and here i will list the most important features

  1. Engine of SQL Server 2019 more powerful in Performance with Intelligent Database Feature from Intelligent Query Processing To support for persistent memory devices, the SQL Server Intelligent Database features improve performance and scalability of all your database workloads without any changes to your application or database design. https://docs.microsoft.com/en-us/sql/relational-databases/performance/intelligent-query-processing?view=sql-server-ver15
  2. Engine of SQL Server 2019 more powerful in Performance with Insert with SQL 2019 more faster: Using Feature Called optimize_for_sequential_key. SQL Server has long suffered from a bottleneck when trying to insert sequential records into a table at very high volume. This is because of contention in memory, SQL Server 2019 introduces an optional feature called “optimize_for_sequential_key” that reduces the effect of these bottlenecks. Microsoft quotes up to 40 percent performance gains with this feature https://techcommunity.microsoft.com/t5/sql-server/behind-the-scenes-on-optimize-for-sequential-key/ba-p/806888
  3. High availability: Up to five synchronous replicas, Secondary-to-primary replica connection redirection
  4. Recovery: Accelerated database recovery Reduce the time to recover after a restart or a long-running transaction rollback with accelerated database recovery (ADR). See Accelerated database recovery. https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/restore-and-recovery-overview-sql-server?view=sql-server-ver15#adr
  5. Mission-critical security enhancement: Audit, Always Encrypted with secure enclaves, Data Discovery & Classification, Certificate management in SQL Server Configuration Manager https://docs.microsoft.com/en-us/sql/sql-server/what-s-new-in-sql-server-ver15?view=sql-server-ver15#mission-critical-security
  6. Monitoring: New DMV for Monitoring DB https://docs.microsoft.com/en-us/sql/sql-server/what-s-new-in-sql-server-ver15?view=sql-server-ver15#monitoring
  7. Resumable online rowstore index build: https://docs.microsoft.com/en-us/sql/relational-databases/indexes/perform-index-operations-online?view=sql-server-ver15
  8. And so many other features https://docs.microsoft.com/en-us/sql/sql-server/what-s-new-in-sql-server-ver15?view=sql-server-ver15

Finally, Microsoft also announced an update for SQL Server 2019, so if your organization typically waits for the first patch of a newly released product, you can install it today.  https://support.microsoft.com/en-us/help/4517790/servicing-update-for-sql-server-2019-rtm