-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathUpload_Download_Blobs_Storage_Account.ps1
57 lines (44 loc) · 1.59 KB
/
Upload_Download_Blobs_Storage_Account.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
49
50
51
52
53
54
55
56
57
Set-Location c:\
Clear-Host
Install-Module -Name Az -Force -AllowClobber -Verbose
#Log into Azure
Connect-AzAccount
#Select the correct subscription
Get-AzSubscription -SubscriptionName "MSDN Platforms" | Select-AzSubscription
Get-AzLocation | select Location
$location = "westeurope"
$resourceGroup = "myResourceGroup"
New-AzResourceGroup -Name $resourceGroup -Location $location
#Create a storage account
$storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroup `
-Name "tw75mystorageaccount" `
-SkuName Standard_LRS `
-Location $location `
$ctx = $storageAccount.Context
#Create a container
$containerName = "quickstartblobs"
New-AzStorageContainer -Name $containerName -Context $ctx -Permission blob
#Upload blobs to the container
#Upload a file
Set-AzStorageBlobContent -File "C:\Users\admin\Desktop\Bilder\IMG_0498.jpg" `
-Container $containerName `
-Blob "IMG_0498.jpg" `
-Context $ctx
#Upload another file
Set-AzStorageBlobContent -File "C:\Users\admin\Desktop\Bilder\IMG_0406.jpg" `
-Container $containerName `
-Blob "IMG_0406.jpg" `
-Context $ctx
#List the blobs in a container
Get-AzStorageBlob -Container $ContainerName -Context $ctx | select Name
#Download blobs
# download first blob
Get-AzStorageBlobContent -Blob "IMG_0498.jpg" `
-Container $containerName `
-Destination "C:\Users\admin\Desktop\Bilder\Downloads\" `
-Context $ctx
#Download another blob
Get-AzStorageBlobContent -Blob "IMG_0406.jpg" `
-Container $containerName `
-Destination "C:\Users\admin\Desktop\Bilder\Downloads\" `
-Context $ctx