-
Notifications
You must be signed in to change notification settings - Fork 9
/
AzureStorageAccounts.azcli
69 lines (53 loc) · 1.9 KB
/
AzureStorageAccounts.azcli
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
58
59
60
61
62
63
64
65
66
67
68
69
#MANAGE STORAGE WiTH AZ CLI
#Create a resource group
az group create \
--name myResourceGroup \
--location eastus
#list azure locations
az account list-locations
#Create a storage account
az storage account create \
--name mystorageaccount \
--resource-group myResourceGroup \
--location eastus \
--sku Standard_LRS \
--encryption blob
--kind StorageV2
#Get Azure Storage account Connection String
az storage account show-connection-string --name "storageaccountcli" --resource-group mac-storage-rg
#Set Connection String as Environment Variable
SET AZURE_STORAGE_CONNECTION_STRING = "ConnectionString"
#Specify storage account credentials
az storage account keys list \
--account-name mystorageaccount \
--resource-group myResourceGroup \
--output table
#set environment variable on linux
export AZURE_STORAGE_ACCOUNT="mystorageaccountname"
export AZURE_STORAGE_KEY="myStorageAccountKey"
#set environment variable on windows
SET AZURE_STORAGE_ACCOUNT="ConnectionString"
#Create a container
az storage container create --name mystoragecontainer
az storage container create --name "containername" --public-access blob
#Change Access Level
az storage container set-permission --name "containername" --public-access container
#Upload a blob
az storage blob upload \
--container-name mystoragecontainer \
--name blobName \
--file ~/path/to/local/file
#This operation creates the blob if it doesn't already exist, and overwrites it if it does. Upload as many files as you like before continuing.
az storage blob upload \
--container-name mystoragecontainer \
--name helloworld \
--file helloworld
#List the blobs in a container
az storage blob list \
--container-name mystoragecontainer \
--output table
#Download a blob
az storage blob download \
--container-name mystoragecontainer \
--name blobName \
--file ~/destination/path/for/file