- Lab
- A Cloud Guru
Creating Azure Storage and Transferring Data Using PowerShell
There may be a time where you find yourself wanting to transfer data from your local workstation into an Azure Storage account. In those cases, there is a PowerShell command for that. PowerShell is a powerful tool, which helps you with a lot of administrative tasks — one of those being transferring files. In this hands-on lab, you will be tasked with using PowerShell to create a storage account and storage container, taking files that reside on a Linux VM, and transferring them to an Azure Storage container.
Path Info
Table of Contents
-
Challenge
Log in to the Linux VM
-
Open a new terminal.
-
Copy the public IP address provided with this hands-on lab.
-
Log in via SSH:
ssh cloud_user@<PUBLIC_IP_OF_THE_VM>
-
Once logged in, start the PowerShell prompt:
pwsh
-
-
Challenge
Install the Az Module and Connect to Azure
-
Install the module:
Install-Module -Name Az -AllowClobber -Scope CurrentUser
-
Enter
Y
to continue installing from the PowerShell gallery. -
From the PowerShell prompt, connect to Azure:
Connect-AzAccount
-
Go to
https://microsoft.com/devicelogin
and enter the code provided in the terminal. -
Enter the username and password provided with this hands-on lab.
-
-
Challenge
Create the Storage Account and Container
-
Create the variable
$location
and set it towestus
. -
Create the variable
$resourceGroup
and assign it to the resource group given with the lab ($resourceGroup = "<RESOURCE_GROUP_WITH_THE_LAB>"
). -
Create the storage account, replacing
<UNIQUE_STORAGE_ACCOUNT_NAME>
with a globally unique name:$storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroup ` -Name "<UNIQUE_STORAGE_ACCOUNT_NAME>" ` -SkuName Standard_LRS ` -Location $location
-
Set the storage context (a reference to the correct storage account):
$ctx = $storageAccount.Context
-
Create the storage container:
$containerName = "images"
New-AzStorageContainer -Name $containerName -Context $ctx -Permission blob
-
-
Challenge
Copy the File into the Storage Container
-
Download the file:
wget http://ww1.prweb.com/prfiles/2019/12/16/16790924/badge-full.png
-
Transfer the file to the newly created storage container:
Set-AzStorageBlobContent -File "./badge-full.png" ` -Container $containerName ` -Blob "badge-full.png" ` -Context $ctx
-
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.