forked from oracle-devrel/oracle-autonomous-database-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-data-lake-storage.sh
More file actions
executable file
·108 lines (89 loc) · 3.38 KB
/
create-data-lake-storage.sh
File metadata and controls
executable file
·108 lines (89 loc) · 3.38 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
# Copyright (c) 2025 Oracle and/or its affiliates.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
echo ""
echo "##"
echo "# Create an Azure Data Lake Storage Gen 2 account"
echo "##"
echo ""
# ensure you update the config file to match your deployment prior to running the deployment
source config
echo "# Creating storage account $STORAGE_ACCOUNT_NAME"
az storage account create \
--name $STORAGE_ACCOUNT_NAME \
--resource-group $RESOURCE_GROUP \
--location $LOCATION \
--sku Standard_LRS \
--kind StorageV2 \
--min-tls-version TLS1_2 \
--https-only true \
--allow-blob-public-access true \
--allow-shared-key-access true \
--default-action Allow \
--bypass AzureServices \
--access-tier Cool \
--public-network-access Enabled \
--encryption-key-source Microsoft.Storage
# Enable access via the portal
az storage account update \
--name $STORAGE_ACCOUNT_NAME \
--resource-group $RESOURCE_GROUP \
--default-action Allow
echo "# Creating container $STORAGE_CONTAINER_NAME"
az storage container create \
--name $STORAGE_CONTAINER_NAME \
--account-name $STORAGE_ACCOUNT_NAME
ACCESS_KEY=`az storage account keys list --account-name $STORAGE_ACCOUNT_NAME --resource-group $RESOURCE_GROUP --query "[0].value" -o tsv`
# Attempt to give current user access to the storage account
echo "# Give privs to access the storage account to the currently signed in user"
STORAGE_ACCOUNT_ID=`az storage account show --name $STORAGE_ACCOUNT_NAME --resource-group $RESOURCE_GROUP --query id -o tsv`
USER_PRINCIPAL_NAME=`az ad signed-in-user show --query userPrincipalName -o tsv`
az role assignment create --assignee "$USER_PRINCIPAL_NAME" --role "Storage Blob Data Owner" --scope $STORAGE_ACCOUNT_ID
echo "# Uploading sample files"
echo "Create the support site directory"
az storage fs directory create \
--account-name $STORAGE_ACCOUNT_NAME \
--file-system $STORAGE_CONTAINER_NAME \
--name support-site \
--account-key $ACCESS_KEY
echo "Upload files to that directory"
az storage fs directory upload \
--account-name $STORAGE_ACCOUNT_NAME \
--file-system $STORAGE_CONTAINER_NAME \
--source "../../sql/support-site/*" \
--destination-path support-site \
--recursive \
--auth-mode login
echo "Create the data directory"
az storage fs directory create \
--account-name $STORAGE_ACCOUNT_NAME \
--file-system $STORAGE_CONTAINER_NAME \
--name data \
--account-key $ACCESS_KEY
echo "Upload files to that directory"
az storage fs directory upload \
--account-name $STORAGE_ACCOUNT_NAME \
--file-system $STORAGE_CONTAINER_NAME \
--source "../../sql/data/*" \
--destination-path data \
--recursive \
--auth-mode login
echo "Done."
az storage blob list \
--account-name $STORAGE_ACCOUNT_NAME \
--container-name $STORAGE_CONTAINER_NAME \
--output table --auth-mode login
echo ""
echo "Storage account: $STORAGE_ACCOUNT_NAME"
echo "Container name : $STORAGE_CONTAINER_NAME"
echo "Access Key:"
az storage account keys list \
--account-name $STORAGE_ACCOUNT_NAME \
--resource-group $RESOURCE_GROUP --query "[0].value" -o tsv
echo "Storage URL:"
STORAGE_URL=$(az storage account show \
--name $STORAGE_ACCOUNT_NAME \
--query primaryEndpoints.blob \
--output tsv)
echo $STORAGE_URL$STORAGE_CONTAINER_NAME
echo ""