@@ -29,11 +29,9 @@ CURRENT_DIR="$(cd "$(dirname "$0")" && pwd)"
2929cd " $CURRENT_DIR " || exit
3030
3131# Choose the appropriate CLI based on the environment
32- # When start_interception is active, 'az' already routes to LocalStack,
33- # so we use 'az' directly to avoid double-wrapping.
3432if [[ $ENVIRONMENT == " LocalStack" ]]; then
35- echo " Using az with LocalStack interception active ."
36- AZ=" az "
33+ echo " Using azlocal for LocalStack emulator environment ."
34+ AZ=" azlocal "
3735else
3836 echo " Using standard az for AzureCloud environment."
3937 AZ=" az"
@@ -120,17 +118,21 @@ else
120118 exit 1
121119fi
122120
123- # For LocalStack, convert https:// to http:// to avoid SSL certificate issues
124- # with self-signed certs on data-plane endpoints
125- if [[ $ENVIRONMENT == " LocalStack" ]]; then
126- BLOB_ENDPOINT=" ${BLOB_ENDPOINT/ https: \/\/ / http: \/\/ } "
127- echo " Converted blob endpoint to HTTP: $BLOB_ENDPOINT "
128- fi
129-
130- # Build connection string
121+ # Build the connection string using the original blob endpoint (resolvable from the host).
131122STORAGE_CONN_STRING=" DefaultEndpointsProtocol=http;AccountName=${STORAGE_ACCOUNT_NAME} ;AccountKey=${STORAGE_ACCOUNT_KEY} ;BlobEndpoint=${BLOB_ENDPOINT} "
132123echo " Connection string built successfully."
133124
125+ # For LocalStack, the ACI emulator configures containers with LocalStack's DNS
126+ # server, so *.localhost.localstack.cloud resolves to the LocalStack container.
127+ # We only need to downgrade HTTPS to HTTP (containers don't have the LS TLS cert).
128+ if [[ $ENVIRONMENT == " LocalStack" ]]; then
129+ CONTAINER_BLOB_ENDPOINT=" ${BLOB_ENDPOINT/ https: \/\/ / http: \/\/ } "
130+ CONTAINER_CONN_STRING=" DefaultEndpointsProtocol=http;AccountName=${STORAGE_ACCOUNT_NAME} ;AccountKey=${STORAGE_ACCOUNT_KEY} ;BlobEndpoint=${CONTAINER_BLOB_ENDPOINT} "
131+ echo " Container blob endpoint: $CONTAINER_BLOB_ENDPOINT "
132+ else
133+ CONTAINER_CONN_STRING=" $STORAGE_CONN_STRING "
134+ fi
135+
134136# =============================================================================
135137# Step 5: Create Blob Container
136138# =============================================================================
@@ -159,17 +161,20 @@ echo ""
159161echo " ============================================================"
160162echo " Step 6: Creating Key Vault [$KEY_VAULT_NAME ]..."
161163echo " ============================================================"
162- $AZ keyvault create \
164+ KV_OUTPUT= $( $AZ keyvault create \
163165 --name " $KEY_VAULT_NAME " \
164166 --resource-group " $RESOURCE_GROUP_NAME " \
165167 --location " $LOCATION " \
166168 --enable-rbac-authorization true \
167- --only-show-errors 1> /dev/null
169+ --only-show-errors 2>&1 )
168170
169171if [ $? -eq 0 ]; then
170172 echo " Key Vault [$KEY_VAULT_NAME ] created successfully."
173+ elif echo " $KV_OUTPUT " | grep -qi " already exists" ; then
174+ echo " Key Vault [$KEY_VAULT_NAME ] already exists, reusing."
171175else
172176 echo " Failed to create Key Vault [$KEY_VAULT_NAME ]."
177+ echo " $KV_OUTPUT "
173178 exit 1
174179fi
175180
@@ -180,10 +185,11 @@ echo ""
180185echo " ============================================================"
181186echo " Step 7: Storing storage connection string in Key Vault..."
182187echo " ============================================================"
188+ # Store the container-friendly connection string so ACI can reach LocalStack
183189$AZ keyvault secret set \
184190 --vault-name " $KEY_VAULT_NAME " \
185191 --name " storage-conn" \
186- --value " $STORAGE_CONN_STRING " \
192+ --value " $CONTAINER_CONN_STRING " \
187193 --only-show-errors 1> /dev/null
188194
189195if [ $? -eq 0 ]; then
@@ -339,6 +345,7 @@ if [ "$USE_ACR_IMAGE" = true ]; then
339345 BLOB_CONTAINER_NAME=" $BLOB_CONTAINER_NAME " \
340346 LOGIN_NAME=" $LOGIN_NAME " \
341347 --ip-address Public \
348+ --dns-name-label " $ACI_GROUP_NAME " \
342349 --ports 80 \
343350 --cpu 1 --memory 1 \
344351 --os-type Linux \
355362 BLOB_CONTAINER_NAME=" $BLOB_CONTAINER_NAME " \
356363 LOGIN_NAME=" $LOGIN_NAME " \
357364 --ip-address Public \
365+ --dns-name-label " $ACI_GROUP_NAME " \
358366 --ports 80 \
359367 --cpu 1 --memory 1 \
360368 --os-type Linux \
@@ -384,6 +392,7 @@ echo "Key Vault: $KEY_VAULT_NAME"
384392echo " ACR: $ACR_NAME ($LOGIN_SERVER )"
385393echo " ACI Container: $ACI_GROUP_NAME "
386394echo " Image: $FULL_IMAGE "
395+ echo " FQDN: ${ACI_GROUP_NAME} .${LOCATION} .azurecontainer.io"
387396echo " "
388397echo " Run 'bash scripts/validate.sh' to verify the deployment."
389398echo " ============================================================"
0 commit comments