Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Microsoft Azure Storage

You're reading from   Learning Microsoft Azure Storage Build large-scale, real-world apps by effectively planning, deploying, and implementing Azure storage solutions

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781785884917
Length 276 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Mohamed Waly Mohamed Waly
Author Profile Icon Mohamed Waly
Mohamed Waly
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Understanding Azure Storage 101 2. Delving into Azure Storage FREE CHAPTER 3. Azure Storage for VMs 4. Implementing Azure SQL Databases 5. Beyond Azure SQL Database Management 6. Azure Backup 7. Azure Site Recovery 8. Extending Your Azure Storage Management

Automating your tasks

It is no surprise that we commonly face repetitive and time-consuming tasks. For example, you might want to create multiple storage accounts. You would have to follow the previous guide multiple times to get your job done. This is why Microsoft supports its Azure services with multiple ways of automating most of the tasks that can be implemented in Azure. Throughout this book, two of the automation methods that Azure supports will be used.

Azure PowerShell

PowerShell is commonly used with most Microsoft products, and Azure is no less important than these products.

Mainly, you can use Azure PowerShell cmdlets to manage your Azure Storage, however, you should be aware that Microsoft Azure has two types of cmdlets: one for the classic portal, and another for the portal we are using.

The main difference between the cmdlets of the classic portal and the current portal is there will be an RM added to the cmdlet of the current portal.

For example, if you want to create a storage account in the classic portal, you would use the following cmdlet:

New-AzureStorageAccount

But for the current portal, you would use:

New-AzureRMStorageAccount

By default, you can use Azure PowerShell cmdlets in Windows PowerShell; you will have to install its module first.

Installing the Azure PowerShell module

Installing the Azure PowerShell module from the PowerShell Gallery

  1. Open PowerShell in elevated mode.
  2. To install the Azure PowerShell module for the current portal, run the Install-Module AzureRM cmdlet. If your PowerShell requires the NuGet provider, you will be asked to agree to install it and you will have to agree to the installation policy modification, as the repository is not available on your environment, as shown in the following screenshot:
Figure 1.10: Installing the AzureRM PowerShell module

Creating a storage account in the Azure portal using PowerShell

  1. Log in to your Azure account using the Login-AzureRmAccount cmdlet. You will be prompted to enter your account credentials:
Figure 1.11: Log in to Azure via PowerShell
  1. Create another storage account with the same properties as we used for the portal, but with a different name:
Figure 1.12: Creating a new storage account using PowerShell
  1. Congratulations! You have created a storage account using PowerShell.

Azure command-line interface

The Azure command-line interface (CLI) is open source, cross-platform, and supports implementing all the tasks you can do in the Azure portal with commands.

Azure CLI comes in two flavors:

  • Azure CLI 2.0, which only supports the current Azure portal
  • Azure CLI 1.0, which supports both portals

Throughout the book, we will be using Azure CLI 2.0. So, let’s get started with its installation.

Installing the Azure CLI 2.0

To understand what the Azure CLI 2.0 is capable of, we need to install it. Let's do so by following these steps:

  1. Download Azure CLI 2.0 from the following link: https://azurecliprod.blob.core.windows.net/msi/azure-cli-2.0.12.msi.
  2. Once downloaded, you can start the installation by following the screenshots shown here:
    1. Run the executable files as administrator, and once the wizard opens, click on Install:
Figure 1.13: Installing the Azure CLI 2.0
    1. Once you click on Install, it will start to validate your environment to check whether it is compatible with it or not, then it starts the installation:
Figure 1.14: Installing Azure CLI 2.0
    1. Once the installation completes, you can click on Finish, and you are good to go:
Figure 1.15: Installing Azure CLI 2.0
  1. Once done, you can open the cmd and type az to access Azure CLI commands, as shown in the following diagram:
Figure 1.16: Opening the Azure CLI using CMD

Creating a Storage account using the Azure CLI 2.0

Let's get our hands dirty with the Azure CLI 2.0 to create an Azure Storage account:

  1. Log in to your Azure account using the az login command. You have to open the URL that pops up on the CLI and enter the code, as shown in the following screenshot:
Figure 1.17: Logging in to Azure via the Azure CLI 2.0
  1. Create another storage account with the same properties as we used for the portal, but with a different name, as shown in the following screenshot:
Figure 1.18: Creating an Azure storage account using the Azure CLI 2.0
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image