{"id":15427370,"url":"https://github.com/pamelafox/staticmaps-function","last_synced_at":"2025-09-07T08:43:46.216Z","repository":{"id":138633475,"uuid":"597250083","full_name":"pamelafox/staticmaps-function","owner":"pamelafox","description":"A FastAPI that can generate maps using the py-staticmaps package. Designed for deployment to Azure Functions + Azure CDN, using the Azure Developer CLI and Bicep files.","archived":false,"fork":false,"pushed_at":"2025-08-12T05:12:40.000Z","size":24331,"stargazers_count":12,"open_issues_count":6,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-12T07:17:49.992Z","etag":null,"topics":["azd-templates","azure-cdn","azure-functions","fastapi","python","static-maps"],"latest_commit_sha":null,"homepage":"","language":"Bicep","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pamelafox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-02-04T00:57:53.000Z","updated_at":"2025-08-12T05:12:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"25ce8397-7c3b-4421-8bb1-b98f1eba049d","html_url":"https://github.com/pamelafox/staticmaps-function","commit_stats":{"total_commits":95,"total_committers":3,"mean_commits":"31.666666666666668","dds":0.4421052631578948,"last_synced_commit":"28c86b473455748c0f5ab7aadd3fa883134d3532"},"previous_names":[],"tags_count":0,"template":true,"template_full_name":"pamelafox/icon-writer-function","purl":"pkg:github/pamelafox/staticmaps-function","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pamelafox%2Fstaticmaps-function","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pamelafox%2Fstaticmaps-function/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pamelafox%2Fstaticmaps-function/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pamelafox%2Fstaticmaps-function/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pamelafox","download_url":"https://codeload.github.com/pamelafox/staticmaps-function/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pamelafox%2Fstaticmaps-function/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274014691,"owners_count":25207687,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-07T02:00:09.463Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["azd-templates","azure-cdn","azure-functions","fastapi","python","static-maps"],"created_at":"2024-10-01T17:59:31.041Z","updated_at":"2025-09-07T08:43:46.191Z","avatar_url":"https://github.com/pamelafox.png","language":"Bicep","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Static Maps API (Function App)\n\nThis repository creates a Static Maps API using\nthe [FastAPI framework](https://fastapi.tiangolo.com/) and\nthe [py-staticmaps](https://pypi.org/project/py-staticmaps/) package.\nThe API accepts query parameters to customize the map and responds with a PNG image.\nThe code is tested with [pytest](https://pypi.org/project/pytest/),\nlinted with [ruff](https://pypi.org/project/ruff/),\nand formatted with [black](https://pypi.org/project/black/).\n\n![Screenshot of FastAPI documentation on left and image map output on right](readme_screenshot.png)\n\nThis API is designed to be deployed as an Azure Function with an Azure CDN in front.\nThe function is secured, so the CDN endpoint uses a rule to pass the function key in the x-function-key header.\nThe CDN endpoint also uses rules to cache the images for 7 days, to reduce unneeded function traffic.\n\n![Architecture diagram for CDN to Function App to FastAPI](readme_diagram.png)\n\n## Opening the project\n\nThis project has Dev Container support, so it will be automatically setup if you open it in Github Codespaces or in local VS Code with the Dev Containers extension.\n\nIf you're unable to open the Dev Container, then you'll need to:\n\n1. Create a [Python virtual environment](https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments) and activate it.\n\n2. Install requirements:\n\n    ```shell\n    python3 -m pip install --user -r requirements-dev.txt\n    ```\n\n3. Install the [Azure Dev CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd).\n\n## Local development\n\nUse the local emulator from Azure Functions Core Tools to test the function locally.\n(There is no local emulator for the API Management service).\n\n1. Open this repository in Github Codespaces or VS Code with Remote Dev Containers extension.\n2. Open the Terminal and make sure you're in the root folder.\n3. Run `func host start --python`\n4. 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.\n\n## Deployment\n\nThis repo is set up for deployment using the\n[Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview),\nwhich relies on the `azure.yaml` file and the configuration files in the `infra` folder.\n\nSteps for deployment:\n\n1. Sign up for a [free Azure account](https://azure.microsoft.com/free/) and create an Azure Subscription.\n2. Login to Azure:\n\n    ```shell\n    azd auth login\n    ```\n\n3. Provision and deploy all the resources:\n\n    ```shell\n    azd up\n    ```\n\n    It will prompt you to provide an `azd` environment name (like \"staticmaps\"), select a subscription from your Azure account, and select a location (like \"eastus\").  Then it will provision the resources in your account and deploy the latest code.\n\n4. Once it finishes deploying, navigate to the API endpoint URL from the output. Since the function is secured, you should see a 401 when navigating to the function endpoint. However, the CDN endpoint should successfully display the documentation.\n\n5. When you've made any changes to the app code, you can just run:\n\n    ```shell\n    azd deploy\n    ```\n\n### CI/CD pipeline\n\nThis project includes a Github workflow for deploying the resources to Azure\non every push to main. That workflow requires several Azure-related authentication secrets to be stored as Github action secrets. To set that up, run:\n\n```shell\nazd pipeline config\n```\n\n### Monitoring\n\nThe deployed resources include a Log Analytics workspace with an Application Insights dashboard to measure metrics like server response time.\n\nTo open that dashboard, run this command once you've deployed:\n\n```shell\nazd monitor --overview\n```\n\n### Costs\n\n(only provided as an example, as of February 2023)\n\nCosts for this architecture are based on incoming traffic / usage, so cost should be near $0 if you're only testing it out, and otherwise increase based on usage.\n\n- Azure CDN - Standard tier, $0.081 per GB for first 10 TB per month. [Pricing](https://azure.microsoft.com/pricing/details/cdn/)\n- Azure Functions - Consumption tier: $0.20 per 1 million calls. The first 1 million calls per Azure subscription are free. [Pricing](https://azure.microsoft.com/pricing/details/functions/)\n- Storage account - Standard tier (Hot): $0.0255 per used GiB, \t$0.065 per 10,000 write transactions. The account is only used to store the function code, so cost depends on size of function code and number of deploys (but should be quite low). [Pricing](https://azure.microsoft.com/pricing/details/storage/files/)\n- Application Insights: $2.88 per GB ingested data. The first 5 GB per billing account are included per month. [Pricing](https://azure.microsoft.com/pricing/details/monitor/)\n\n### Load testing\n\nThis repository includes `locustfile.py` for use with the Python [locust](https://docs.locust.io/)\nframework for performance testing.\n\nModify that test based on your anticipated usage and run the following command,\nsubstituting the host name with your CDN host name:\n\n```shell\nlocust --headless --users 10 --spawn-rate 1 -H https://YOUR-ENDPOINT.azureedge.net/\n```\n\n### Tile providers\n\nThe py-staticmaps project offers several tile providers as options, all based on OpenStreetMap.\nBefore using their tiles in production, read through their tile usage guidelines:\n\n* [OpenStreetMap](https://operations.osmfoundation.org/policies/tiles/)\n* [Stamen Maps](http://maps.stamen.com/#watercolor/12/37.7706/-122.3782)\n\n## Getting help\n\nIf you're working with this project and running into issues, please post in **Discussions**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpamelafox%2Fstaticmaps-function","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpamelafox%2Fstaticmaps-function","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpamelafox%2Fstaticmaps-function/lists"}