Create Blob storage, upload files and list in AZURE PS

Copy the following ps script to your ps1 file and run in Azure PS

# Connect Azure account
# All Variables
$location = “southindia”
$resourceGroup = “blobtestmanu”
$storageGroupName = “blobstoragemanu”
$containerName = “manublobcontainer”
$FileName1 = “C:\Users\mphilip\Desktop\Azure\maxresdefault.jpg”
$FileName2 =”C:\Users\mphilip\Desktop\Azure\tasks.txt”
$Blobname1 = “maxresdefault.jpg”
$Blobname2 = “Tasks.txt”
# Create new Resource Group
New-AzureRmResourceGroup -Name $resourceGroup -Location $location
# Create new blob storage account
$storageAccount = New-AzureRmStorageAccount -ResourceGroupName $resourceGroup -Name $storageGroupName -Location $location -SkuName Standard_LRS
$ctx = $storageAccount.Context
# Create new container
new-azurestoragecontainer -Name $containerName -Context $ctx -Permission blob
# upload a file from local computer
set-azurestorageblobcontent -File $FileName1 -Container $containerName -Blob $Blobname1 -Context $ctx
# upload another file  from local computer
set-azurestorageblobcontent -File $Blobname1 -Container $containerName -Blob $Blobname2 -Context $ctx
# List files in blob
get-azurestorageblob -Container $ContainerName -Context $ctx | select Name

TechNet Reference below:


No responses yet

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Comments