Skip to content

dennisseah/azure-fn-map

Repository files navigation

azure-fn-map

This is a simple example on how to expose Azure Map API with Azure Function in Python.

1. Setup

Create Resource Group, Azure Map and Function App

When creating Function App, please have the followings

  1. Runtime stack = Python
  2. Version=3.8 (or a version that matches your Python version)

and add an Application Setting under Configuration Section

SUBSCRIPTION_ID=<the primary/secondary key of Azure map>

git clone

git clone https://github.com/dennisseah/azure-fn-map.git

Setup Python Virtual Environment & install Python packages

you use python (instead of python3) if you are not on mac-osx

cd azure-fn-map.git
python3 -m venv venv
source venv/bin/activate
pip3 install -r requirements.txt
pip3 install -r requirements-dev.txt

Install Azure Functions Extension for VSCode

2. Development

open vscode on the current git folder

code .

create a file, local.settings.json. The content of this file is

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "",
    "FUNCTIONS_WORKER_RUNTIME": "python",
    "SUBSCRIPTION_ID": "<the primary/secondary key of Azure map>"
  }
}

I have my .vscode/launch.json like this

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to Python Functions",
            "type": "python",
            "request": "attach",
            "port": 9091,
            "preLaunchTask": "func: host start"
        }
    ]
}

I have my .vscode/settings.json like this

{
    "python.pythonPath": "venv/bin/python",
    "azureFunctions.deploySubpath": ".",
    "azureFunctions.scmDoBuildDuringDeployment": true,
    "azureFunctions.pythonVenv": "venv",
    "azureFunctions.projectLanguage": "Python",
    "azureFunctions.projectRuntime": "~3",
    "debug.internalConsoleOptions": "neverOpen"
}

I have my .vscode/extensions.json like this

{
  "recommendations": [
    "ms-azuretools.vscode-azurefunctions",
    "ms-python.python"
  ]
}

Debugging

Click on the Run Icon on the Left Icon Panel, and then click on the Attach to Python Functions option. Once the debugger is up, you can point your browser to

http://localhost:7071/api/AddressSearch
http://localhost:7071/api/ReverseGeo

Deploying to Azure Function App.

Click on the Azure Icon on the Left Icon Panel, and then click Deploy to Function App icon. Select the subscription and function app accordingly. Once the deployment is done, you can point your browser to

http://<function-app-host>/api/AddressSearch
http://<function-app-host>/api/ReverseGeo

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages