-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-storage-create.sh
executable file
·44 lines (36 loc) · 1.12 KB
/
azure-storage-create.sh
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
#!/usr/bin/env bash
set -x
AZURE_GROUP_NAME=""
AZURE_CONTAINER_NAME="redlib"
AZURE_STORAGE_ACCOUNT_NAME="$AZURE_CONTAINER_NAME$((1 + RANDOM % 1000))"
LOCATION=""
# create the storage account
az storage account create \
--resource-group "$AZURE_GROUP_NAME" \
--name "$AZURE_STORAGE_ACCOUNT_NAME" \
--location "$LOCATION" \
--sku Standard_LRS
# create the file share
az storage share create \
--name "$AZURE_CONTAINER_NAME" \
--account-name "$AZURE_STORAGE_ACCOUNT_NAME"
STORAGE_KEY=$(
az storage account keys list \
--resource-group "$AZURE_GROUP_NAME" \
--account-name "$AZURE_STORAGE_ACCOUNT_NAME" \
--query "[0].value" --output tsv
)
# upload Caddyfile
az storage file upload \
--account-key "$STORAGE_KEY" \
--account-name "$AZURE_STORAGE_ACCOUNT_NAME" \
--share-name "$AZURE_CONTAINER_NAME" \
--source Caddyfile
# upload ca.cert
az storage file upload \
--account-key "$STORAGE_KEY" \
--account-name "$AZURE_STORAGE_ACCOUNT_NAME" \
--share-name "$AZURE_CONTAINER_NAME" \
--source certs/ca.cert
echo "$AZURE_STORAGE_ACCOUNT_NAME"
echo "$STORAGE_KEY"