In this article, you will see how to upload blob contents in Azure Storage Account using PowerShell.
Install the Azure PowerShell Module:
Open Windows PowerShell window and run the below command.
Install-Module -Name Az –AllowClobber
![](https://static.wixstatic.com/media/0b3d63_853dcf7d9f374dd09b4360557f14ffee~mv2.png/v1/fill/w_980,h_200,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/0b3d63_853dcf7d9f374dd09b4360557f14ffee~mv2.png)
Download Blob Contents:
Open a text file. Copy and paste the below script. Save the file as script.ps1.
################# Azure Blob Storage - PowerShell ####################
## Input Parameters
$resourceGroupName="psspschennairg"
$storageAccName="psspschennaistorageacc"
$storageContainerName="container001"
$fileName="testdoc"
$filePath=".\testdoc.docx"
## Connect to Azure Account
Connect-AzAccount
## Function to upload blob contents
Function UploadBlobContent
{
Write-Host -ForegroundColor Green "Uploading blob content.."
## Get the storage account
$storageAcc=Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccName
## Get the storage account context
$ctx=$storageAcc.Context
## Upload a file
Set-AzStorageBlobContent -Container $storageContainerName -File $filePath -Blob $fileName -Context $ctx -Force
}
UploadBlobContent
## Disconnect from Azure Account
Disconnect-AzAccount
######################################################################
Open Windows PowerShell window and navigate to the location where the script file was saved.
Run the following command.
.\script.ps1
![](https://static.wixstatic.com/media/0b3d63_94cbbba639ed423995a31c7c960aa682~mv2.png/v1/fill/w_980,h_515,al_c,q_90,usm_0.66_1.00_0.01,enc_auto/0b3d63_94cbbba639ed423995a31c7c960aa682~mv2.png)
Result:
Blob contents uploaded successfully as shown below.
![](https://static.wixstatic.com/media/0b3d63_e6625638d8aa49039724de73d0c56f0e~mv2.png/v1/fill/w_690,h_539,al_c,q_90,enc_auto/0b3d63_e6625638d8aa49039724de73d0c56f0e~mv2.png)
Summary:
Thus in this article you saw how to upload blob contents in Azure Storage Account using PowerShell.
Kommentare