-
Notifications
You must be signed in to change notification settings - Fork 62
/
07_Create_Blob_Container.ps1
57 lines (44 loc) · 1.5 KB
/
07_Create_Blob_Container.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
Connect-AzAccount
# Are we connected?
Get-AzResourceGroup
Get-AzLocation | select Location
$location = "westeurope"
# Create a resource group
$resourceGroup = "myResourceGroup"
New-AzResourceGroup -Name $resourceGroup -Location $location
# Create a storage account
$storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroup `
-Name "twstorageazure" `
-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:\azure_bilder\Mustang_1.JPG" `
-Container $containerName `
-Blob "Mustang_1.JPG" `
-Context $ctx
# upload another file
Set-AzStorageBlobContent -File "C:\azure_bilder\Trackhawk_2.jpg" `
-Container $containerName `
-Blob "Trackhawk_2.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 "Mustang_1.JPG" `
-Container $containerName `
-Destination "C:\azure_bilder\Downloads\" `
-Context $ctx
# download another blob
Get-AzStorageBlobContent -Blob "Trackhawk_2.jpg" `
-Container $containerName `
-Destination "C:\azure_bilder\Downloads\" `
-Context $ctx