Skip to content

Commit ebe52d2

Browse files
enable public access sample data storage account
1 parent d579159 commit ebe52d2

2 files changed

Lines changed: 90 additions & 8 deletions

File tree

.github/workflows/import-sample-data-cosmosdb.yml

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,61 @@ jobs:
3131
- name: Checkout Code
3232
uses: actions/checkout@v4
3333

34-
- name: Download Sample Data from Azure Storage
34+
- name: Login to Azure for Sample Data Download
3535
shell: bash
36-
env:
37-
STORAGE_ACCOUNT_NAME: ${{ vars.SAMPLE_DATA_STORAGE_ACCOUNT_NAME }}
38-
STORAGE_CONTAINER_NAME: ${{ vars.SAMPLE_DATA_STORAGE_CONTAINER_NAME }}
3936
run: |
4037
echo "🔐 Logging into Azure to download sample data files..."
4138
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
4239
az account set --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }}
4340
41+
- name: Enable Public Access on Sample Data Storage (if disabled)
42+
id: sample_storage_access
43+
shell: bash
44+
env:
45+
STORAGE_ACCOUNT_NAME: ${{ vars.SAMPLE_DATA_STORAGE_ACCOUNT_NAME }}
46+
run: |
47+
echo "🔍 Checking public network access on sample data storage account '${STORAGE_ACCOUNT_NAME}'..."
48+
49+
# Discover the resource group for the sample data storage account
50+
SAMPLE_STORAGE_RG=$(az storage account list --query "[?name=='${STORAGE_ACCOUNT_NAME}'].resourceGroup | [0]" -o tsv)
51+
if [ -z "$SAMPLE_STORAGE_RG" ] || [ "$SAMPLE_STORAGE_RG" == "null" ]; then
52+
echo "❌ Could not find resource group for storage account '${STORAGE_ACCOUNT_NAME}'."
53+
exit 1
54+
fi
55+
echo "SAMPLE_STORAGE_RG=$SAMPLE_STORAGE_RG" >> $GITHUB_ENV
56+
echo "SAMPLE_STORAGE_RG=$SAMPLE_STORAGE_RG" >> $GITHUB_OUTPUT
57+
58+
CURRENT_ACCESS=$(az storage account show --name "$STORAGE_ACCOUNT_NAME" --resource-group "$SAMPLE_STORAGE_RG" --query "publicNetworkAccess" -o tsv)
59+
CURRENT_DEFAULT_ACTION=$(az storage account show --name "$STORAGE_ACCOUNT_NAME" --resource-group "$SAMPLE_STORAGE_RG" --query "networkRuleSet.defaultAction" -o tsv)
60+
61+
echo " Current publicNetworkAccess: $CURRENT_ACCESS"
62+
echo " Current defaultAction: $CURRENT_DEFAULT_ACTION"
63+
64+
NEEDS_RESTORE="false"
65+
if [ "$CURRENT_ACCESS" == "Disabled" ] || [ "$CURRENT_DEFAULT_ACTION" == "Deny" ]; then
66+
echo "🔓 Enabling public access on sample data storage account..."
67+
az storage account update --name "$STORAGE_ACCOUNT_NAME" --resource-group "$SAMPLE_STORAGE_RG" --public-network-access Enabled --output none
68+
az storage account update --name "$STORAGE_ACCOUNT_NAME" --resource-group "$SAMPLE_STORAGE_RG" --default-action Allow --output none
69+
NEEDS_RESTORE="true"
70+
71+
echo "⏳ Waiting 30 seconds for network changes to propagate..."
72+
sleep 30
73+
echo "✅ Public access enabled on sample data storage account."
74+
else
75+
echo "✅ Public access is already enabled."
76+
fi
77+
78+
echo "NEEDS_RESTORE=$NEEDS_RESTORE" >> $GITHUB_ENV
79+
echo "NEEDS_RESTORE=$NEEDS_RESTORE" >> $GITHUB_OUTPUT
80+
echo "ORIGINAL_ACCESS=$CURRENT_ACCESS" >> $GITHUB_ENV
81+
echo "ORIGINAL_DEFAULT_ACTION=$CURRENT_DEFAULT_ACTION" >> $GITHUB_ENV
82+
83+
- name: Download Sample Data from Azure Storage
84+
shell: bash
85+
env:
86+
STORAGE_ACCOUNT_NAME: ${{ vars.SAMPLE_DATA_STORAGE_ACCOUNT_NAME }}
87+
STORAGE_CONTAINER_NAME: ${{ vars.SAMPLE_DATA_STORAGE_CONTAINER_NAME }}
88+
run: |
4489
SAMPLE_DATA_DIR="${RUNNER_TEMP}/sample-data"
4590
mkdir -p "$SAMPLE_DATA_DIR"
4691

.github/workflows/import-sample-data-postgresql.yml

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,53 @@ jobs:
3131
- name: Checkout Code
3232
uses: actions/checkout@v4
3333

34-
- name: Download Sample Data from Azure Storage
34+
- name: Login to Azure for Sample Data Download
3535
shell: bash
36-
env:
37-
STORAGE_ACCOUNT_NAME: ${{ vars.SAMPLE_DATA_STORAGE_ACCOUNT_NAME }}
38-
STORAGE_CONTAINER_NAME: ${{ vars.SAMPLE_DATA_STORAGE_CONTAINER_NAME }}
3936
run: |
4037
echo "🔐 Logging into Azure to download sample data files..."
4138
az login --service-principal -u ${{ secrets.AZURE_CLIENT_ID }} -p ${{ secrets.AZURE_CLIENT_SECRET }} --tenant ${{ secrets.AZURE_TENANT_ID }}
4239
az account set --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }}
4340
41+
- name: Enable Public Access on Sample Data Storage (if disabled)
42+
id: sample_storage_access
43+
shell: bash
44+
env:
45+
STORAGE_ACCOUNT_NAME: ${{ vars.SAMPLE_DATA_STORAGE_ACCOUNT_NAME }}
46+
run: |
47+
echo "🔍 Checking public network access on sample data storage account '${STORAGE_ACCOUNT_NAME}'..."
48+
49+
# Discover the resource group for the sample data storage account
50+
SAMPLE_STORAGE_RG=$(az storage account list --query "[?name=='${STORAGE_ACCOUNT_NAME}'].resourceGroup | [0]" -o tsv)
51+
if [ -z "$SAMPLE_STORAGE_RG" ] || [ "$SAMPLE_STORAGE_RG" == "null" ]; then
52+
echo "❌ Could not find resource group for storage account '${STORAGE_ACCOUNT_NAME}'."
53+
exit 1
54+
fi
55+
echo "SAMPLE_STORAGE_RG=$SAMPLE_STORAGE_RG" >> $GITHUB_ENV
56+
57+
CURRENT_ACCESS=$(az storage account show --name "$STORAGE_ACCOUNT_NAME" --resource-group "$SAMPLE_STORAGE_RG" --query "publicNetworkAccess" -o tsv)
58+
CURRENT_DEFAULT_ACTION=$(az storage account show --name "$STORAGE_ACCOUNT_NAME" --resource-group "$SAMPLE_STORAGE_RG" --query "networkRuleSet.defaultAction" -o tsv)
59+
60+
echo " Current publicNetworkAccess: $CURRENT_ACCESS"
61+
echo " Current defaultAction: $CURRENT_DEFAULT_ACTION"
62+
63+
if [ "$CURRENT_ACCESS" == "Disabled" ] || [ "$CURRENT_DEFAULT_ACTION" == "Deny" ]; then
64+
echo "🔓 Enabling public access on sample data storage account..."
65+
az storage account update --name "$STORAGE_ACCOUNT_NAME" --resource-group "$SAMPLE_STORAGE_RG" --public-network-access Enabled --output none
66+
az storage account update --name "$STORAGE_ACCOUNT_NAME" --resource-group "$SAMPLE_STORAGE_RG" --default-action Allow --output none
67+
68+
echo "⏳ Waiting 30 seconds for network changes to propagate..."
69+
sleep 30
70+
echo "✅ Public access enabled on sample data storage account."
71+
else
72+
echo "✅ Public access is already enabled."
73+
fi
74+
75+
- name: Download Sample Data from Azure Storage
76+
shell: bash
77+
env:
78+
STORAGE_ACCOUNT_NAME: ${{ vars.SAMPLE_DATA_STORAGE_ACCOUNT_NAME }}
79+
STORAGE_CONTAINER_NAME: ${{ vars.SAMPLE_DATA_STORAGE_CONTAINER_NAME }}
80+
run: |
4481
SAMPLE_DATA_DIR="${RUNNER_TEMP}/sample-data"
4582
mkdir -p "$SAMPLE_DATA_DIR"
4683

0 commit comments

Comments
 (0)