Skip to content

Commit

Permalink
Merge pull request #25 from pamelafox/upgrade-v2
Browse files Browse the repository at this point in the history
Updating programming model
  • Loading branch information
pamelafox committed Jul 3, 2023
2 parents 4f7f71d + 495e254 commit eaeef9d
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 33 deletions.
7 changes: 1 addition & 6 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
"label": "func: host start",
"command": "host start --python",
"problemMatcher": "$func-python-watch",
"isBackground": true,
"options": {
"env": {
"PYTHON_ISOLATE_WORKER_DEPENDENCIES": "1"
}
}
"isBackground": true
}
]
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Use the local emulator from Azure Functions Core Tools to test the function loca

1. Open this repository in Github Codespaces or VS Code with Remote Dev Containers extension.
2. Open the Terminal and make sure you're in the root folder.
3. Run `PYTHON_ISOLATE_WORKER_DEPENDENCIES=1 func host start --python`
3. Run `func host start --python`
4. Click 'http://localhost:7071/{*route}' in the terminal, which should open a website in a new tab. Change the URL to "/" to see the auto-generated documentation and try generating a map.

## Deployment
Expand Down
5 changes: 0 additions & 5 deletions function/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os

import azure.functions
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
Expand All @@ -19,7 +18,3 @@ async def startup_event():
tracer = TracerProvider(resource=Resource({SERVICE_NAME: "api"}))
tracer.add_span_processor(BatchSpanProcessor(exporter))
FastAPIInstrumentor.instrument_app(fastapi_app, tracer_provider=tracer)


async def main(req: azure.functions.HttpRequest, context: azure.functions.Context) -> azure.functions.HttpResponse:
return await azure.functions.AsgiMiddleware(fastapi_app).handle_async(req, context)
20 changes: 0 additions & 20 deletions function/function.json

This file was deleted.

5 changes: 5 additions & 0 deletions function_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import azure.functions as func

from function import fastapi_app

app = func.AsgiFunctionApp(app=fastapi_app, http_auth_level=func.AuthLevel.FUNCTION)
2 changes: 1 addition & 1 deletion infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module functionApp 'core/host/functions.bicep' = {
tags: union(tags, { 'azd-service-name': 'api' })
alwaysOn: false
appSettings: {
PYTHON_ISOLATE_WORKER_DEPENDENCIES: 1
AzureWebJobsFeatureFlags: 'EnableWorkerIndexing'
}
applicationInsightsName: monitoring.outputs.applicationInsightsName
appServicePlanId: appServicePlan.outputs.id
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

azure-functions>=1.12.0
py-staticmaps==0.4.0
Pillow==9.5.0
fastapi==0.98.0
nest-asyncio==1.5.6
opentelemetry-instrumentation-fastapi==0.39b0
Expand Down

0 comments on commit eaeef9d

Please sign in to comment.