Skip to content

Commit 86d2ac2

Browse files
committed
Enhance error handling in blob download and DZI conversion processes
1 parent fe13ece commit 86d2ac2

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ This Azure Function automatically processes Whole Slide Images (WSI) uploaded to
7777
### Docker Build & Deploy
7878
1. Build the Docker image:
7979
```sh
80-
docker build -t <your-image-name> .
80+
# For Apple Silicon (ARM64) or multi-arch systems, add --platform to avoid base image warnings:
81+
docker build --platform=linux/amd64 -t <your-image-name> .
82+
# Or, for ARM64 base images:
83+
docker build --platform=linux/arm64 -t <your-image-name> .
84+
# If you are unsure, use the platform that matches your deployment target (Azure Functions Premium is amd64/x86_64).
8185
```
8286
2. Run locally:
8387
```sh

function_app.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,24 @@ async def blob_to_dzi_eventgrid_trigger(event: func.EventGridEvent):
5353
return
5454

5555
blob_service_client = BlobServiceClient.from_connection_string(conn_str)
56-
temp_blob_path = await asyncio.to_thread(
57-
download_blob_to_temp, blob_service_client, container_name, blob_name
58-
)
59-
if not temp_blob_path:
56+
try:
57+
temp_blob_path = await asyncio.to_thread(
58+
download_blob_to_temp, blob_service_client, container_name, blob_name
59+
)
60+
if not temp_blob_path:
61+
logger.error("Failed to download blob to temp file: %s/%s", container_name, blob_name)
62+
return
63+
except Exception as exc:
64+
logger.error("Exception during blob download: %s", exc, exc_info=True)
6065
return
6166

62-
dzi_output_dir = await asyncio.to_thread(convert_to_dzi, temp_blob_path, blob_name)
63-
if not dzi_output_dir:
67+
try:
68+
dzi_output_dir = await asyncio.to_thread(convert_to_dzi, temp_blob_path, blob_name)
69+
if not dzi_output_dir:
70+
logger.error("DZI conversion failed for blob: %s", blob_name)
71+
return
72+
except Exception as exc:
73+
logger.error("Exception during DZI conversion: %s", exc, exc_info=True)
6474
return
6575

6676
dest_url = os.environ.get("DZI_UPLOAD_DEST_URL")

0 commit comments

Comments
 (0)