Skip to content

Commit 7d09cd0

Browse files
authored
Merge pull request #30 from Azure-Samples/gk/azurite-bindings-fixes
Refactors devcontainer and grants user access
2 parents cfd41ac + 0929d03 commit 7d09cd0

File tree

4 files changed

+15
-31
lines changed

4 files changed

+15
-31
lines changed

.devcontainer/devcontainer.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
"features": {
77
"ghcr.io/devcontainers/features/azure-cli:1": {},
88
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
9-
"ghcr.io/devcontainers/features/node:1": { "version": "lts" },
10-
11-
// Starts Azurite (blob/queue/table) automatically on container boot
12-
"ghcr.io/devcontainers/features/azurite:1": {}
9+
"ghcr.io/devcontainers/features/node:1": { "version": "lts" }
1310
},
1411

1512
// ── Port forwards ───────────────────────────────────────────────────────
@@ -25,8 +22,7 @@
2522
"extensions": [
2623
"ms-azuretools.vscode-azurefunctions",
2724
"ms-azuretools.vscode-docker",
28-
"GitHub.copilot",
29-
"Azurite.azurite" // UI & table explorer
25+
"GitHub.copilot"
3026
]
3127
}
3228
},

.devcontainer/start.sh

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,6 @@ if [[ -f .venv/bin/activate ]]; then
1212
source .venv/bin/activate
1313
fi
1414

15-
# ── Cosmos DB Linux emulator ──────────────────────────────────────────────
16-
# Runs in gateway mode so the default connection string against localhost works.
17-
if ! docker ps --filter "name=cosmos-emu" --format '{{.Names}}' | grep -q cosmos-emu; then
18-
echo "▶ Starting Cosmos DB emulator container"
19-
docker run -d --name cosmos-emu \
20-
-p 8081:8081 -p 8900:8900 \
21-
mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
22-
fi
23-
24-
# ── Azurite storage emulator (blob / queue / table) ───────────────────────
25-
if ! pgrep -f "azurite.*--location" >/dev/null; then
26-
echo "▶ Starting Azurite storage emulator"
27-
AZURITE_DATA_DIR="$REPO_ROOT/.azurite"
28-
mkdir -p "$AZURITE_DATA_DIR"
29-
nohup azurite --silent \
30-
--location "$AZURITE_DATA_DIR" \
31-
--blobHost 0.0.0.0 --queueHost 0.0.0.0 --tableHost 0.0.0.0 \
32-
> "$AZURITE_DATA_DIR/azurite.log" 2>&1 &
33-
fi
34-
35-
# The Functions host needs a storage connection string even when using Azurite.
36-
export AzureWebJobsStorage="UseDevelopmentStorage=true"
37-
3815
# ── Azure Functions runtime ───────────────────────────────────────────────
3916
echo "▶ func start (port 7071)"
4017
func start --python --no-build --port 7071

infra/main.bicep

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,17 @@ module blobRoleAssignmentApi 'app/rbac/storage-Access.bicep' = {
9494
}
9595
}
9696

97+
// Allow user access to blob storage
98+
module userBlobRoleAssignmentApi 'app/rbac/storage-Access.bicep' = {
99+
name: 'userBlobRoleAssignmentApi'
100+
scope: rg
101+
params: {
102+
storageAccountName: storage.outputs.name
103+
roleDefinitionID: StorageBlobDataOwner
104+
principalID: deployer().objectId
105+
}
106+
}
107+
97108
// Allow access from api to queue storage using a managed identity
98109
module queueRoleAssignmentApi 'app/rbac/storage-Access.bicep' = {
99110
name: 'queueRoleAssignmentapi'

src/function_app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def to_dict(self):
122122
# HTTP endpoint for saving snippets
123123
# This is accessible via standard HTTP POST requests
124124
@app.route(route="snippets", methods=["POST"], auth_level=func.AuthLevel.FUNCTION)
125-
@app.embeddings_input(arg_name="embeddings", input="{code}", input_type="rawText", model="%EMBEDDING_MODEL_DEPLOYMENT_NAME%")
125+
@app.embeddings_input(arg_name="embeddings", input="{code}", input_type="rawText", embeddingsModel="%EMBEDDING_MODEL_DEPLOYMENT_NAME%")
126126
async def http_save_snippet(req: func.HttpRequest, embeddings: str) -> func.HttpResponse:
127127
"""
128128
HTTP trigger function to save a code snippet with its vector embedding.
@@ -199,7 +199,7 @@ async def http_save_snippet(req: func.HttpRequest, embeddings: str) -> func.Http
199199
description="Saves a given code snippet. It can take a snippet name, the snippet content, and an optional project ID. Embeddings are generated for the content to enable semantic search. The LLM should provide 'snippetname' and 'snippet' when intending to save.",
200200
toolProperties=tool_properties_save_snippets_json,
201201
)
202-
@app.embeddings_input(arg_name="embeddings", input="{arguments.snippet}", input_type="rawText", model="%EMBEDDING_MODEL_DEPLOYMENT_NAME%")
202+
@app.embeddings_input(arg_name="embeddings", input="{arguments.snippet}", input_type="rawText", embeddingsModel="%EMBEDDING_MODEL_DEPLOYMENT_NAME%")
203203
async def mcp_save_snippet(context: str, embeddings: str) -> str:
204204
"""
205205
MCP tool to save a code snippet with vector embedding.

0 commit comments

Comments
 (0)