You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add Pylint configuration and implement Azure Function for WSI to DZI processing
- Create GitHub Actions workflow for linting Python code with Pylint.
- Add Pylint configuration file with max line length set to 150.
- Update README to reflect project name and clarify input formats.
- Implement functions for downloading blobs, converting images to DZI, and cleaning up temporary files.
- Integrate AzCopy for uploading DZI outputs to Azure Blob Storage.
- Enhance logging for better traceability during processing.
This Azure Function automatically processes Whole Slide Images (WSI) uploaded to Azure Blob Storage, converting them into Deep Zoom Image (DZI) format using `pyvips`. It is designed to handle very large files (up to several GB) efficiently and is suitable for digital pathology, microscopy, and similar domains.
11
11
12
12
-**Trigger:** Event Grid (on blob upload)
13
-
-**Input:** Image blob (e.g., `.jpg`, `.tif`) in a monitored container
13
+
-**Input:** Image blob (e.g., `.svs`, `.tiff`) in a monitored container
14
14
-**Output:** DZI tiles and metadata uploaded to a designated output container
> This function is built and deployed using Docker because the `libvips` library (required by `pyvips`) is not supported on standard Azure Functions hosting options such as Flex Consumption, Consumption, or App Service plans. Docker allows you to include all necessary native dependencies for reliable execution on the Premium plan or in a custom container environment.
@@ -28,6 +28,12 @@ This Azure Function automatically processes Whole Slide Images (WSI) uploaded to
28
28
```
29
29
├── Dockerfile
30
30
├── function_app.py
31
+
├── parse_event_blob_url.py
32
+
├── parse_container_and_blob.py
33
+
├── download_blob_to_temp.py
34
+
├── convert_to_dzi.py
35
+
├── upload_with_azcopy.py
36
+
├── cleanup_temp_files.py
31
37
├── host.json
32
38
├── local.settings.json
33
39
├── requirements.txt
@@ -155,7 +161,13 @@ Create a file named `event.json` with the following content:
@@ -181,4 +193,37 @@ curl -X POST "http://localhost:7071/runtime/webhooks/EventGrid?functionName=blob
181
193
- Make sure all dependencies are installed and the correct Python version is used.
182
194
183
195
---
184
-
*For more, see the Azure Functions [local development docs](https://learn.microsoft.com/azure/azure-functions/functions-develop-local).*
196
+
197
+
## AzCopy Authentication: Managed Identity and SAS Token
198
+
199
+
This function uploads DZI output directories to Azure Blob Storage using AzCopy. Two authentication methods are supported:
200
+
201
+
### 1. Managed Identity (Recommended for Production)
202
+
-**How it works:**
203
+
- The Azure Function runs with a User-Assigned or System-Assigned Managed Identity.
204
+
- AzCopy uses the identity to obtain an OAuth token and authenticate to Azure Blob Storage.
205
+
-**Requirements:**
206
+
- The Function App's Managed Identity must have at least `Storage Blob Data Contributor` role on the target storage account or container.
207
+
- No secrets or connection strings are required in code or environment variables.
208
+
-**How to use:**
209
+
- Ensure the Function App is assigned a Managed Identity in Azure.
210
+
- Grant the identity access to the storage account/container.
211
+
-**Important:** Set the environment variable `AZCOPY_AUTO_LOGIN_TYPE` to `MSI`.
212
+
- AzCopy will automatically use the identity for authentication when running inside Azure.
213
+
214
+
### 2. SAS Token (For Local Development or Special Cases)
215
+
-**How it works:**
216
+
- AzCopy authenticates using a Shared Access Signature (SAS) token appended to the destination Blob Storage URL.
217
+
-**Requirements:**
218
+
- A valid SAS token with write permissions for the target container or directory.
219
+
-**How to use:**
220
+
- Generate a SAS token for the storage account or container.
221
+
- Append the SAS token to the destination URL in the AzCopy command (e.g., `https://<account>.blob.core.windows.net/<container>?<sas-token>`).
222
+
- This method is useful for local testing or scenarios where Managed Identity is not available.
223
+
224
+
> **Best Practice:**
225
+
> Use Managed Identity for all production deployments to avoid secret management and improve security. SAS tokens should only be used for local development or temporary access.
226
+
227
+
Please feel free to reach out to me if you have any questions or need further assistance with the WSI Slide Image to DZI Processor project. Your feedback and contributions are always welcome!
0 commit comments