This Script was created to create File Share & upload file on Azure

Simply edit the PS1 file based on the comments in the file to match your environment

Be sure to take note of the comments in the PS1 file to insert your input according to your environment.

PowerShell
Edit|Remove
## Enter the input data on first 3 lines 
## Enter Storage Account name e.g. azure15 
## Enter share Name e.g. assets 
## Enter folder share e.g. invoice 
 
$storageAccountName = "<Storage Account Name>" 
$shareName = "<Share Name>" 
$folderName = "<Folder Name>" 
 
# Get the storage account key and context 
$storageAccountKey = (Get-AzureStorageKey -StorageAccountName $storageAccountName).Primary 
$ctx = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey 
 
 
 
# create a share 
 
$s = New-AzureStorageShare -Name $shareName -Context $ctx 
 
 
 
# create a new folder in the share 
 
New-AzureStorageDirectory -Share $s -Path $folderName 
 
 
 
# Find the folder where this script is saved 
$thisfolder = Split-Path -parent $MyInvocation.MyCommand.Definition 
 
# The local source subfolder 
$sourcefolder = "$thisfolder\$folderName" 
 
 
 
#Upload each file in the local subfolder to the folder in the share 
$files = Get-ChildItem $sourcefolder 
foreach($file in $files){ 
  $fileName = "$sourcefolder\$file" 
  Set-AzureStorageFileContent -Share $s -Source $fileName -Path $folderName 
} 
 
 

You can use this script in following steps:    

  1. Download the script.
  2. Open it using PowerShell
  3. Edit on top of the script file, and then enter storage account name, folder name & share name.
  4. Save the file and then run the script on the computer.