diff --git a/samples/function-app-managed-identity/python/scripts/input.txt b/samples/function-app-managed-identity/python/scripts/input.txt index 2963a6c..ea442d9 100644 --- a/samples/function-app-managed-identity/python/scripts/input.txt +++ b/samples/function-app-managed-identity/python/scripts/input.txt @@ -1 +1 @@ -Azure managed identities provide an identity for Azure services to use when connecting to other Azure services that support Microsoft Entra ID authentication, eliminating the need to manage credentials in code. They function as a special type of service principal, managed by Azure, and have two types: system-assigned (tied to a single resource's lifecycle) and user-assigned (a standalone resource that can be shared across multiple resources). Key benefits include simplified credential management and improved security, as Azure automatically handles the rotation and protection of credentials. \ No newline at end of file +Hi mate, how are you? \ No newline at end of file diff --git a/samples/function-app-managed-identity/python/scripts/test.sh b/samples/function-app-managed-identity/python/scripts/test.sh index 374a7a5..02cea01 100755 --- a/samples/function-app-managed-identity/python/scripts/test.sh +++ b/samples/function-app-managed-identity/python/scripts/test.sh @@ -8,6 +8,15 @@ INPUT_CONTAINER_NAME="input" OUTPUT_CONTAINER_NAME="output" STORAGE_ACCOUNT_NAME="${PREFIX}storage${SUFFIX}" CURRENT_DIR="$(cd "$(dirname "$0")" && pwd)" +TEMP_OUTPUT_FILE="" + +cleanup() { + if [ -n "$TEMP_OUTPUT_FILE" ] && [ -f "$TEMP_OUTPUT_FILE" ]; then + rm -f "$TEMP_OUTPUT_FILE" + fi +} + +trap cleanup EXIT # Change the current directory to the script's directory cd "$CURRENT_DIR" || exit @@ -101,6 +110,23 @@ for ((i=1; i<=n; i++)); do if [ "$BLOB_EXISTS" == "true" ]; then echo "Processed file [$BLOB_NAME] found in the [$OUTPUT_CONTAINER_NAME] container." + TEMP_OUTPUT_FILE="$(mktemp "${TMPDIR:-/tmp}/processed-output.XXXXXX")" || { echo "Failed to create temporary file." >&2; exit 1; } + + az storage blob download \ + --container-name "$OUTPUT_CONTAINER_NAME" \ + --name "$BLOB_NAME" \ + --file "$TEMP_OUTPUT_FILE" \ + --account-name "$STORAGE_ACCOUNT_NAME" \ + --auth-mode login 1>/dev/null || { echo "Failed to download processed blob [$BLOB_NAME] from container [$OUTPUT_CONTAINER_NAME]." >&2; exit 1; } + + echo "Input file [$FILE_PATH]:" + cat "$FILE_PATH" + + echo "" + echo "Processed output file [$BLOB_NAME]:" + cat "$TEMP_OUTPUT_FILE" + echo "" + exit 0 fi