Azure
Function¶
TiTiler is built on top of FastAPI, a modern, fast, Python web framework for building APIs. We can make our FastAPI application work as an Azure Function by wrapping it within the Azure Function Python worker.
If you are not familiar with Azure functions we recommend checking docs.microsoft.com/en-us/azure/azure-functions/ first.
Minimal TiTiler Azure function code:
import azure.functions as func
from titiler.application.main import cog, mosaic, stac, tms
from fastapi import FastAPI
app = FastAPI()
app.include_router(cog.router, prefix="/cog", tags=["Cloud Optimized GeoTIFF"])
app.include_router(
stac.router, prefix="/stac", tags=["SpatioTemporal Asset Catalog"]
)
app.include_router(mosaic.router, prefix="/mosaicjson", tags=["MosaicJSON"])
app.include_router(tms.router, tags=["TileMatrixSets"])
async def main(
req: func.HttpRequest, context: func.Context,
) -> func.HttpResponse:
return await func.AsgiMiddleware(app).handle_async(req, context)
Requirements¶
- Azure CLI: docs.microsoft.com/en-us/cli/azure/install-azure-cli
- Azure Function Tool: docs.microsoft.com/en-us/azure/azure-functions/functions-run-local
Deployment¶
$ git clone https://github.com/developmentseed/titiler.git
$ cd titiler/deployment/azure
$ az login
$ az group create --name AzureFunctionsTiTiler-rg --location eastus
$ az storage account create --name {your-new-storage-name} --sku Standard_LRS -g AzureFunctionsTiTiler-rg
$ az functionapp create --consumption-plan-location eastus --runtime python --runtime-version 3.9 --functions-version 4 --name {your-new-function-name} --os-type linux -g AzureFunctionsTiTiler-rg -s {your-new-storage-name}
$ func azure functionapp publish titiler --python
or