Microsoft Azure

How To Upload Files to Microsoft Azure

In this post I will show you how to upload files to an Azure storage account. This can be useful if you want to perform an offline upload of virtual hard disks, tools, or scripts.

Prepare the Storage Account

A file must be uploaded into a container in a storage account. Containers are like folders; a logical mechanism for organizing files in Azure. In my example, I want to upload a PowerShell script to Azure, so I will create a container called scripts. You can do this in two ways, the GUI or PowerShell.

In the management portal, browse into your storage account, click Containers, and click Add. Name the container, set the access level and close the wizard. Note that the name must be in lowercase.

Create a new Azure storage account container (Image credit: Aidan Finn)
Create a new Azure storage account container (Image Credit: Aidan Finn)

In case you are curious, the access option controls if and how the public can access the contents of your container:

Sponsored Content

Maximize Value from Microsoft Defender

In this ebook, you’ll learn why Red Canary’s platform and expertise bring you the highest possible value from your Microsoft Defender for Endpoint investment, deployment, or migration.

Control access to an Azure storage account container (Image Credit: Aidan Finn)
Control access to an Azure storage account container (Image Credit: Aidan Finn)

Alternatively, you can create a new container using PowerShell. Note that before we go anywhere, we must set a default storage account for use with PowerShell. This is a little annoying; you cannot specify a storage account in each storage cmdlet. Instead you have to change the default storage account each time.

The syntax for setting a default storage account is:

Set-AzureSubscription –SubscrptionName <name of your Azure subscription> -CurrentStorageAccountName <name of the storage account>

In my example, I am working with a storage account called petridemo in a subscription called Azure in Open:
Set-AzureSubscription –SubscrptionName “Azure in Open” -CurrentStorageAccountName petridemo

Now I can use New-AzureStorageContainer to create the new container to store my future upload:
New-AzureStorageContainer –Name scripts

Upload the File

Microsoft offers you PowerShell as the solution for uploading files to an Azure storage account. There are some third-party solutions that offer a UI, but for the purposes of this article, we’ll stick with Microsoft’s method, which is based on a cmdlet called Set-AzureStorageBlobContent:

Set-AzureStorageBlobContent –Container <name of destination container in Azure> -File <path and name of file to upload> -Blob <what the file name will be in Azure>

In my example, I am going to upload C:\Temp\ServerCore.ps1 to my new scripts container in the petridemo storage account.

I have already set my default storage account using Set-AzureSubscription. Now I can run Set-AzureStorageBlobContent:

Set-AzureStorageBlobContent –Container scripts -File C:\Temp\ServerCore.ps1 -Blob ServerCore.ps1

A progress bar appears in the PowerShell console to indicate upload progress. One the job is done, you can browse into your storage account container to verify that the upload is completed.

Verifying that the file was uploaded to the Azure Storage Account [Image Credit: Aidan Finn]
Verifying that the file was uploaded to the Azure Storage Account [Image Credit: Aidan Finn]
 

Related Topics:

BECOME A PETRI MEMBER:

Don't have a login but want to join the conversation? Sign up for a Petri Account

Register
Comments (0)

Leave a Reply

Aidan Finn, Microsoft Most Valuable Professional (MVP), has been working in IT since 1996. He has worked as a consultant and administrator for the likes of Innofactor Norway, Amdahl DMR, Fujitsu, Barclays and Hypo Real Estate Bank International where he dealt with large and complex IT infrastructures and MicroWarehouse Ltd. where he worked with Microsoft partners in the small/medium business space.
External Sharing and Guest User Access in Microsoft 365 and Teams

This eBook will dive into policy considerations you need to make when creating and managing guest user access to your Teams network, as well as the different layers of guest access and the common challenges that accompany a more complicated Microsoft 365 infrastructure.

You will learn:

  • Who should be allowed to be invited as a guest?
  • What type of guests should be able to access files in SharePoint and OneDrive?
  • How should guests be offboarded?
  • How should you determine who has access to sensitive information in your environment?

Sponsored by: