generated from hmcts/service-hmcts-crime-springboot-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathazurite-seed.sh
More file actions
46 lines (37 loc) · 1.26 KB
/
azurite-seed.sh
File metadata and controls
46 lines (37 loc) · 1.26 KB
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
#!/bin/sh
set -eu
CS="${AZURE_STORAGE_CONNECTION_STRING}"
echo "Waiting for Azurite..."
i=0
until az storage container list --connection-string "$CS" >/dev/null 2>&1; do
i=$((i+1))
[ "$i" -lt 60 ] || { echo "Azurite not ready"; exit 1; }
sleep 1
done
echo "Creating documents container..."
az storage container create \
--name documents \
--public-access blob \
--connection-string "$CS" >/dev/null
echo "Enforcing public access..."
az storage container set-permission \
--name documents \
--public-access blob \
--connection-string "$CS" >/dev/null
echo "Uploading source.pdf..."
[ -f /seed/source.pdf ] || { echo "Missing /seed/source.pdf"; ls -la /seed; exit 1; }
az storage blob upload \
--overwrite true \
--container-name documents \
--name source.pdf \
--file /seed/source.pdf \
--content-type application/pdf \
--connection-string "$CS" >/dev/null
echo "Verifying source blob exists..."
az storage blob show \
--container-name documents \
--name source.pdf \
--connection-string "$CS" >/dev/null
ACL="$(az storage container show --name documents --connection-string "$CS" --query properties.publicAccess -o tsv || true)"
echo "documents publicAccess=$ACL"
echo "Seeded URL: http://azurite:10000/devstoreaccount1/documents/source.pdf"