-
Notifications
You must be signed in to change notification settings - Fork 9
/
AzureStorageAccounts.ps1
48 lines (38 loc) · 1.29 KB
/
AzureStorageAccounts.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#MANAGE STORAGE WiTH POWERSHELL
Connect-AzureRMAccount
Get-AzureRMLocation | select Location
$location = "westeurope"
$resourceGroup = "myResourceGroup"
New-AzureRMResourceGroup -Name $resourceGroup -Location $location
#Create a storage account
$storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroup `
-Name "mystorageaccount" `
-SkuName Standard_LRS `
-Location $location `
$ctx = $storageAccount.Context
#Create a container
$containerName = "quickstartblobs"
new-AzurermStoragecontainer -Name $containerName -Context $ctx -Permission blob
# upload a file
set-AzStorageblobcontent -File "D:\_TestImages\Image001.jpg" `
-Container $containerName `
-Blob "Image001.jpg" `
-Context $ctx
# upload another file
set-AzStorageblobcontent -File "D:\_TestImages\Image002.png" `
-Container $containerName `
-Blob "Image002.png" `
-Context $ctx
#List the blobs in a container
Get-AzStorageBlob -Container $ContainerName -Context $ctx | select Name
#Download blobs
# download first blob
Get-AzStorageblobcontent -Blob "Image001.jpg" `
-Container $containerName `
-Destination "D:\_TestImages\Downloads\" `
-Context $ctx
# download another blob
Get-AzStorageblobcontent -Blob "Image002.png" `
-Container $containerName `
-Destination "D:\_TestImages\Downloads\" `
-Context $ctx