Skip to content

Commit 0d21c56

Browse files
committed
add sample, update resource links
1 parent 3f0607d commit 0d21c56

File tree

8 files changed

+103
-3
lines changed

8 files changed

+103
-3
lines changed

docker/AzureFunctionsBaseImage.Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ LABEL org.opencontainers.image.source=https://github.com/esri/arcgis-python-api
1010

1111
# install dependencies, then clean yum cache
1212
RUN apt-get update && apt-get install -y gcc libkrb5-dev krb5-config krb5-user && apt-get clean && rm -rf /var/lib/apt/lists/*
13+
RUN pip3 install azure-functions && rm -rf /home/.cache/pip
1314
# install arcgis
1415
ARG arcgis_version="2.3.1"
1516
# adding .* ensures the latest patch version is installed

docker/README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,34 @@ Push to your _private_ AWS ECR instance, and configure lambda to run from this c
2929

3030
#### ghcr.io/esri/arcgis-python-api-azure-functions:latest
3131

32+
[Sample](samples/AzureFunctions)
33+
3234
To use this image, setup your dockerfile like
3335
```
3436
FROM ghcr.io/esri/arcgis-python-api-azure-functions:latest
3537
COPY . /home/site/wwwroot
3638
```
3739

3840
Your copied resources will need to include:
39-
- `function.json`, such as https://github.com/Azure/azure-functions-docker-python-sample/blob/dev/HttpTrigger/function.json
40-
- `main.py`, such as:
41+
- `host.json`, with your appsettings
42+
- `function_app.py`, such as:
4143

4244
```
4345
import arcgis
4446
import azure.functions as func
4547
48+
app = func.FunctionApp()
49+
50+
@app.http_trigger(route='GET /', methods=['get'])
4651
def main(req: func.HttpRequest) -> func.HttpResponse:
4752
return func.HttpResponse(f"Hello from Azure Functions using ArcGIS API for Python {arcgis.__version__}!")
4853
```
4954

55+
Push to the container registry of your choice.
56+
5057
For futher information, see:
58+
59+
- https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=asgi%2Capplication-level&pivots=python-mode-decorators#programming-model
60+
- https://learn.microsoft.com/en-us/azure/azure-functions/functions-deploy-container-apps?tabs=acr%2Cbash&pivots=programming-language-python#create-and-test-the-local-functions-project
5161
- https://github.com/Azure/azure-functions-python-worker
52-
- https://github.com/Azure/azure-functions-docker-python-sample
5362
- https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-custom-container
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
local.settings.json
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
bin
2+
obj
3+
csx
4+
.vs
5+
edge
6+
Publish
7+
8+
*.user
9+
*.suo
10+
*.cscfg
11+
*.Cache
12+
project.lock.json
13+
14+
/packages
15+
/TestResults
16+
17+
/tools/NuGet.exe
18+
/App_Data
19+
/secrets
20+
/data
21+
.secrets
22+
appsettings.json
23+
local.settings.json
24+
25+
node_modules
26+
dist
27+
28+
# Local python packages
29+
.python_packages/
30+
31+
# Python Environments
32+
.env
33+
.venv
34+
env/
35+
venv/
36+
ENV/
37+
env.bak/
38+
venv.bak/
39+
40+
# Byte-compiled / optimized / DLL files
41+
__pycache__/
42+
*.py[cod]
43+
*$py.class
44+
45+
# Azurite artifacts
46+
__blobstorage__
47+
__queuestorage__
48+
__azurite_db*__.json
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"ms-azuretools.vscode-azurefunctions"
4+
]
5+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM ghcr.io/esri/arcgis-python-api-azure-functions:latest
2+
3+
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
4+
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
5+
6+
COPY . /home/site/wwwroot
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# templated from `func init --worker-runtime python --docker`
2+
# see https://learn.microsoft.com/en-us/azure/azure-functions/functions-deploy-container-apps?tabs=acr%2Cbash&pivots=programming-language-python#create-and-test-the-local-functions-project
3+
# and https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=asgi%2Capplication-level&pivots=python-mode-decorators#programming-model
4+
import arcgis
5+
import azure.functions as func
6+
7+
# NOTE: this is anonymous for sample/testing only,
8+
# configure your authentication properly for production
9+
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
10+
11+
@app.function_name('HttpTrigger1')
12+
@app.route(route='hello')
13+
def main(req: func.HttpRequest) -> func.HttpResponse:
14+
return func.HttpResponse(f"Hello from Azure Functions using ArcGIS API for Python {arcgis.__version__}!")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"FUNCTIONS_WORKER_RUNTIME": "python",
3+
"version": "2.0",
4+
"logging": {
5+
"applicationInsights": {
6+
"samplingSettings": {
7+
"isEnabled": true,
8+
"excludedTypes": "Request"
9+
}
10+
}
11+
},
12+
"extensionBundle": {
13+
"id": "Microsoft.Azure.Functions.ExtensionBundle",
14+
"version": "[4.*, 5.0.0)"
15+
}
16+
}

0 commit comments

Comments
 (0)