From 1e23b7b9f113592fb37f25abfb6605e3ba71f90a Mon Sep 17 00:00:00 2001 From: Jay Roebuck Date: Mon, 22 Sep 2025 12:35:31 -0400 Subject: [PATCH 1/2] remove legacy AzureFunctions sample --- .../DockerBuild.AzureFunctionsBaseImage.yaml | 73 ------------------- docker/AzureFunctionsBaseImage.Dockerfile | 17 ----- docker/README.md | 34 +-------- docker/samples/AzureFunctions/.dockerignore | 1 - docker/samples/AzureFunctions/.gitignore | 48 ------------ .../AzureFunctions/.vscode/extensions.json | 5 -- docker/samples/AzureFunctions/Dockerfile | 6 -- docker/samples/AzureFunctions/function_app.py | 14 ---- docker/samples/AzureFunctions/host.json | 16 ---- 9 files changed, 1 insertion(+), 213 deletions(-) delete mode 100644 .github/workflows/DockerBuild.AzureFunctionsBaseImage.yaml delete mode 100644 docker/AzureFunctionsBaseImage.Dockerfile delete mode 100644 docker/samples/AzureFunctions/.dockerignore delete mode 100644 docker/samples/AzureFunctions/.gitignore delete mode 100644 docker/samples/AzureFunctions/.vscode/extensions.json delete mode 100644 docker/samples/AzureFunctions/Dockerfile delete mode 100644 docker/samples/AzureFunctions/function_app.py delete mode 100644 docker/samples/AzureFunctions/host.json diff --git a/.github/workflows/DockerBuild.AzureFunctionsBaseImage.yaml b/.github/workflows/DockerBuild.AzureFunctionsBaseImage.yaml deleted file mode 100644 index e065d96831..0000000000 --- a/.github/workflows/DockerBuild.AzureFunctionsBaseImage.yaml +++ /dev/null @@ -1,73 +0,0 @@ -name: DockerBuild.AzureFunctionsImage - -permissions: - contents: read - packages: write - -on: - # allow it to be run on-demand - workflow_dispatch: - inputs: - version: - description: "Version of ArcGIS API for Python to install in the image" - type: string - default: "2.4.1" - python_version: - description: "Python version to base image on" - type: string - default: "3.11" - is_latest_release: - description: "Version of ArcGIS API for Python is Latest current release" - type: boolean - default: false - is_default_supported_python: - description: "Python version is default supported version (i.e. python used by Pro and Enterprise)" - type: boolean - default: false - -jobs: - build-and-push: - name: Build Docker image and push to ghcr.io - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Github Packages - uses: docker/login-action@v3 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ghcr.io/esri/arcgis-python-api-azure-functions - tags: | - type=raw,value=${{ inputs.version }}-python${{ inputs.python_version }} - type=raw,value=${{ inputs.version }},enable=${{ inputs.is_default_supported_python && github.ref_name == github.event.repository.default_branch }} - type=raw,value=latest,enable=${{ inputs.is_latest_release && inputs.is_default_supported_python && github.ref_name == github.event.repository.default_branch }} - type=schedule,pattern={{date 'YY.MM'}},enable=${{ inputs.is_latest_release && inputs.is_default_supported_python && github.ref_name == github.event.repository.default_branch }} - - - id: docker_build - name: Build image and push to GitHub Container Registry - uses: docker/build-push-action@v6 - with: - # relative path to the place where source code with Dockerfile is located - context: . - file: ./docker/AzureFunctionsBaseImage.Dockerfile - build-args: | - python_version=${{ inputs.python_version }} - arcgis_version=${{ inputs.version }} - tags: ${{ steps.meta.outputs.tags }} - provenance: false - platforms: linux/amd64 - push: true \ No newline at end of file diff --git a/docker/AzureFunctionsBaseImage.Dockerfile b/docker/AzureFunctionsBaseImage.Dockerfile deleted file mode 100644 index 74f3bb490b..0000000000 --- a/docker/AzureFunctionsBaseImage.Dockerfile +++ /dev/null @@ -1,17 +0,0 @@ -ARG python_version=3.11 -# azure-functions python image, defaults to python 3.11 -FROM mcr.microsoft.com/azure-functions/python:4-python${python_version} - -# set metadata -LABEL org.opencontainers.image.authors="jroebuck@esri.com" -LABEL org.opencontainers.image.description="Azure Functions image with arcgis Python API and its Linux dependencies preinstalled" -LABEL org.opencontainers.image.licenses=Apache -LABEL org.opencontainers.image.source=https://github.com/esri/arcgis-python-api - -# install dependencies, then clean yum cache -RUN apt-get update && apt-get install -y gcc libkrb5-dev krb5-config krb5-user && apt-get clean && rm -rf /var/lib/apt/lists/* -RUN pip3 install azure-functions && rm -rf /home/.cache/pip -# install arcgis -ARG arcgis_version="2.4.1" -# adding .* ensures the latest patch version is installed -RUN pip3 install "arcgis==${arcgis_version}.*" && rm -rf /home/.cache/pip diff --git a/docker/README.md b/docker/README.md index 966bf6ba6a..faeebb06fe 100644 --- a/docker/README.md +++ b/docker/README.md @@ -27,36 +27,4 @@ Push to your _private_ AWS ECR instance, and configure lambda to run from this c ## AzureFunctionsBaseImage -#### ghcr.io/esri/arcgis-python-api-azure-functions:latest - -[Sample](samples/AzureFunctions) - -To use this image, setup your dockerfile like -``` -FROM ghcr.io/esri/arcgis-python-api-azure-functions:latest -COPY . /home/site/wwwroot -``` - -Your copied resources will need to include: -- `host.json`, with your appsettings -- `function_app.py`, such as: - -``` -import arcgis -import azure.functions as func - -app = func.FunctionApp() - -@app.http_trigger(route='GET /', methods=['get']) -def main(req: func.HttpRequest) -> func.HttpResponse: - return func.HttpResponse(f"Hello from Azure Functions using ArcGIS API for Python {arcgis.__version__}!") -``` - -Push to the container registry of your choice. - -For futher information, see: - -- https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=asgi%2Capplication-level&pivots=python-mode-decorators#programming-model -- 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 -- https://github.com/Azure/azure-functions-python-worker -- https://learn.microsoft.com/en-us/azure/azure-functions/functions-how-to-custom-container \ No newline at end of file +The AzureFunctionsBase image has been deprecated in favor of using the standard runtime for Azure Functions development. \ No newline at end of file diff --git a/docker/samples/AzureFunctions/.dockerignore b/docker/samples/AzureFunctions/.dockerignore deleted file mode 100644 index 1927772bc2..0000000000 --- a/docker/samples/AzureFunctions/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -local.settings.json \ No newline at end of file diff --git a/docker/samples/AzureFunctions/.gitignore b/docker/samples/AzureFunctions/.gitignore deleted file mode 100644 index f15ac3fc66..0000000000 --- a/docker/samples/AzureFunctions/.gitignore +++ /dev/null @@ -1,48 +0,0 @@ -bin -obj -csx -.vs -edge -Publish - -*.user -*.suo -*.cscfg -*.Cache -project.lock.json - -/packages -/TestResults - -/tools/NuGet.exe -/App_Data -/secrets -/data -.secrets -appsettings.json -local.settings.json - -node_modules -dist - -# Local python packages -.python_packages/ - -# Python Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# Azurite artifacts -__blobstorage__ -__queuestorage__ -__azurite_db*__.json \ No newline at end of file diff --git a/docker/samples/AzureFunctions/.vscode/extensions.json b/docker/samples/AzureFunctions/.vscode/extensions.json deleted file mode 100644 index dde673dcd0..0000000000 --- a/docker/samples/AzureFunctions/.vscode/extensions.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "recommendations": [ - "ms-azuretools.vscode-azurefunctions" - ] -} \ No newline at end of file diff --git a/docker/samples/AzureFunctions/Dockerfile b/docker/samples/AzureFunctions/Dockerfile deleted file mode 100644 index 1e34ec83a0..0000000000 --- a/docker/samples/AzureFunctions/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM ghcr.io/esri/arcgis-python-api-azure-functions:latest - -ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ - AzureFunctionsJobHost__Logging__Console__IsEnabled=true - -COPY . /home/site/wwwroot \ No newline at end of file diff --git a/docker/samples/AzureFunctions/function_app.py b/docker/samples/AzureFunctions/function_app.py deleted file mode 100644 index 856306ea7b..0000000000 --- a/docker/samples/AzureFunctions/function_app.py +++ /dev/null @@ -1,14 +0,0 @@ -# templated from `func init --worker-runtime python --docker` -# 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 -# and https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=asgi%2Capplication-level&pivots=python-mode-decorators#programming-model -import arcgis -import azure.functions as func - -# NOTE: this is anonymous for sample/testing only, -# configure your authentication properly for production -app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS) - -@app.function_name('HttpTrigger1') -@app.route(route='hello') -def main(req: func.HttpRequest) -> func.HttpResponse: - return func.HttpResponse(f"Hello from Azure Functions using ArcGIS API for Python {arcgis.__version__}!") \ No newline at end of file diff --git a/docker/samples/AzureFunctions/host.json b/docker/samples/AzureFunctions/host.json deleted file mode 100644 index e0991851bf..0000000000 --- a/docker/samples/AzureFunctions/host.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "FUNCTIONS_WORKER_RUNTIME": "python", - "version": "2.0", - "logging": { - "applicationInsights": { - "samplingSettings": { - "isEnabled": true, - "excludedTypes": "Request" - } - } - }, - "extensionBundle": { - "id": "Microsoft.Azure.Functions.ExtensionBundle", - "version": "[4.*, 5.0.0)" - } -} \ No newline at end of file From 52e9c7cc5fbc3151156d2961d2360da435e33bae Mon Sep 17 00:00:00 2001 From: Jay Roebuck Date: Mon, 22 Sep 2025 13:36:53 -0400 Subject: [PATCH 2/2] update AzureFunctions sample to use non-containerized approach --- .vscode/extensions.json | 6 + .vscode/launch.json | 15 ++ .vscode/settings.json | 10 ++ .vscode/tasks.json | 33 +++++ docker/README.md | 4 +- samples/devops_azure_functions/.funcignore | 8 ++ samples/devops_azure_functions/.gitignore | 135 ++++++++++++++++++ .../devops_azure_functions/function_app.py | 10 ++ samples/devops_azure_functions/host.json | 15 ++ .../devops_azure_functions/requirements.txt | 2 + 10 files changed, 237 insertions(+), 1 deletion(-) create mode 100644 .vscode/extensions.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json create mode 100644 samples/devops_azure_functions/.funcignore create mode 100644 samples/devops_azure_functions/.gitignore create mode 100644 samples/devops_azure_functions/function_app.py create mode 100644 samples/devops_azure_functions/host.json create mode 100644 samples/devops_azure_functions/requirements.txt diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000000..3f63eb97df --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "ms-azuretools.vscode-azurefunctions", + "ms-python.python" + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..9a244283d7 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,15 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Attach to Python Functions", + "type": "debugpy", + "request": "attach", + "connect": { + "host": "localhost", + "port": 9091 + }, + "preLaunchTask": "func: host start" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..8f8d0881a9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "azureFunctions.deploySubpath": "samples/devops_azure_functions", + "azureFunctions.scmDoBuildDuringDeployment": true, + "azureFunctions.pythonVenv": ".venv", + "azureFunctions.projectLanguage": "Python", + "azureFunctions.projectRuntime": "~4", + "debug.internalConsoleOptions": "neverOpen", + "azureFunctions.projectLanguageModel": 2, + "azureFunctions.projectSubpath": "samples/devops_azure_functions" +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000..e9caa6b10f --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,33 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "func", + "label": "func: host start", + "command": "host start", + "problemMatcher": "$func-python-watch", + "isBackground": true, + "dependsOn": "pip install (functions)", + "options": { + "cwd": "${workspaceFolder}/samples/devops_azure_functions" + } + }, + { + "label": "pip install (functions)", + "type": "shell", + "osx": { + "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt" + }, + "windows": { + "command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt" + }, + "linux": { + "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt" + }, + "problemMatcher": [], + "options": { + "cwd": "${workspaceFolder}/samples/devops_azure_functions" + } + } + ] +} \ No newline at end of file diff --git a/docker/README.md b/docker/README.md index faeebb06fe..68656c8dd1 100644 --- a/docker/README.md +++ b/docker/README.md @@ -27,4 +27,6 @@ Push to your _private_ AWS ECR instance, and configure lambda to run from this c ## AzureFunctionsBaseImage -The AzureFunctionsBase image has been deprecated in favor of using the standard runtime for Azure Functions development. \ No newline at end of file +The AzureFunctionsBase image has been deprecated in favor of using the standard runtime for Azure Functions development. + +See `samples/devops_azure_functions` for a sample using the standard runtime deployment. \ No newline at end of file diff --git a/samples/devops_azure_functions/.funcignore b/samples/devops_azure_functions/.funcignore new file mode 100644 index 0000000000..9966315f80 --- /dev/null +++ b/samples/devops_azure_functions/.funcignore @@ -0,0 +1,8 @@ +.git* +.vscode +__azurite_db*__.json +__blobstorage__ +__queuestorage__ +local.settings.json +test +.venv \ No newline at end of file diff --git a/samples/devops_azure_functions/.gitignore b/samples/devops_azure_functions/.gitignore new file mode 100644 index 0000000000..7685fc4ac8 --- /dev/null +++ b/samples/devops_azure_functions/.gitignore @@ -0,0 +1,135 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don’t work, or not +# install all needed dependencies. +#Pipfile.lock + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# Azure Functions artifacts +bin +obj +appsettings.json +local.settings.json + +# Azurite artifacts +__blobstorage__ +__queuestorage__ +__azurite_db*__.json +.python_packages \ No newline at end of file diff --git a/samples/devops_azure_functions/function_app.py b/samples/devops_azure_functions/function_app.py new file mode 100644 index 0000000000..fa3d5c76b3 --- /dev/null +++ b/samples/devops_azure_functions/function_app.py @@ -0,0 +1,10 @@ +import azure.functions as func +import logging +import arcgis + +app = func.FunctionApp(http_auth_level=func.AuthLevel.FUNCTION) + +@app.route(route="hello") +def hello(req: func.HttpRequest) -> func.HttpResponse: + logging.info('Python HTTP trigger function processed `hello` request.') + return func.HttpResponse(f"Hello from Azure Functions using ArcGIS API for Python {arcgis.__version__}!") diff --git a/samples/devops_azure_functions/host.json b/samples/devops_azure_functions/host.json new file mode 100644 index 0000000000..9df913614d --- /dev/null +++ b/samples/devops_azure_functions/host.json @@ -0,0 +1,15 @@ +{ + "version": "2.0", + "logging": { + "applicationInsights": { + "samplingSettings": { + "isEnabled": true, + "excludedTypes": "Request" + } + } + }, + "extensionBundle": { + "id": "Microsoft.Azure.Functions.ExtensionBundle", + "version": "[4.*, 5.0.0)" + } +} \ No newline at end of file diff --git a/samples/devops_azure_functions/requirements.txt b/samples/devops_azure_functions/requirements.txt new file mode 100644 index 0000000000..0c16038fac --- /dev/null +++ b/samples/devops_azure_functions/requirements.txt @@ -0,0 +1,2 @@ +azure-functions +arcgis==2.4.1