Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit d91c24e

Browse files
azurite python script
1 parent 72aeb2f commit d91c24e

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

compose.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ services:
4949
networks:
5050
- backend
5151

52+
azurite-setup:
53+
container_name: azurite-setup
54+
build:
55+
context: ./
56+
dockerfile: ./setup/azurite/Dockerfile
57+
network_mode: host
58+
depends_on:
59+
- azurite
60+
environment:
61+
- AZURITE_CONNECTION_STRING=${AZURITE_CONNECTION_STRING}
62+
5263
db:
5364
container_name: "db"
5465
image: mcr.microsoft.com/mssql/server:2022-latest

setup/azurite/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM python:3.13-slim
2+
3+
COPY ./setup/azurite .
4+
RUN pip install --no-cache-dir azure-storage-blob==12.22.0 && pip install azure-storage-queue
5+
CMD ["python3", "-u", "./azurite-setup.py"]

setup/azurite/azurite-setup.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import os
2+
from azure.storage.blob import BlobServiceClient
3+
from azure.storage.queue import QueueServiceClient
4+
from azure.core.exceptions import ResourceExistsError
5+
6+
def setup_azurite():
7+
connection_string = os.getenv("AZURITE_CONNECTION_STRING")
8+
9+
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
10+
queue_service_client = QueueServiceClient.from_connection_string(connection_string)
11+
print("Connected to Azurite")
12+
13+
try:
14+
blob_service_client.create_container("blob-data-service")
15+
queue_service_client.create_queue("queue1")
16+
print("Queues & blob containers created")
17+
except ResourceExistsError:
18+
print("Queues & blob containers already exist")
19+
20+
setup_azurite()

0 commit comments

Comments
 (0)