|
| 1 | +# Microsoft Azure |
| 2 | + |
| 3 | +PMTiles can be served from a [Azure Container App]() using the [go-pmtiles Docker image](https://hub.docker.com/repository/docker/protomaps/go-pmtiles/general). |
| 4 | + |
| 5 | +## Blob Storage |
| 6 | + |
| 7 | +PMTiles should stored in a [Azure Blob Storage](https://azure.microsoft.com/en-us/products/storage/blobs) container. |
| 8 | + |
| 9 | +Make note of the **Storage Account Name**, region and **container name** (e.g. `main`) for the below steps. |
| 10 | + |
| 11 | +## Creating an Azure Container App |
| 12 | + |
| 13 | +1. In [**Create Container App**](https://portal.azure.com/#browse/Microsoft.App%2FcontainerApps), choose the same Azure region as your storage bucket. Create a new **Container Apps Environment** if necessary. |
| 14 | + |
| 15 | +2. In **Container Details**, name your container and choose **Docker Hub or other registries** as the Image Source. |
| 16 | + |
| 17 | + * For **Image and Tag** input `protomaps/go-pmtiles:v1.20.1` |
| 18 | + |
| 19 | + * For **Command Override** input: |
| 20 | + |
| 21 | +``` |
| 22 | + /go-pmtiles, serve, ., --bucket=azblob://main?storage_account=account, --public-url=https://example.com |
| 23 | +``` |
| 24 | + |
| 25 | + * Substitute `main` for your Blob Storage container name, `account` for your Storage Account name, and `https://example.com` for the final user-facing URL you intended your tiles to be served from. If you leave this blank, TileJSON won't work. |
| 26 | + |
| 27 | +3. In the **Ingress** tab, Enable Ingress and choose **Accepting Traffic from Anywhere**. Enter `8080` for the **Target Port**. |
| 28 | + |
| 29 | +4. After validation runs, create your Container App. |
| 30 | + |
| 31 | +## Service Connector |
| 32 | + |
| 33 | +You Azure Container App needs read access to your Azure Storage Blob. |
| 34 | + |
| 35 | +After it's initially created, choose **Service Connector (preview) > Create**. |
| 36 | + |
| 37 | +1. for **Service Type**, choose **Storage - Blob**. |
| 38 | + |
| 39 | +2. Choose any connection name. |
| 40 | + |
| 41 | +3. In the **Authentication** tab, choose **Connection String**. Click the **Advanced** tag and rename the `AZURE_STORAGEBLOB_CONNECTIONSTRING` environment variable to `AZURE_STORAGE_CONNECTION_STRING`. |
| 42 | + |
| 43 | +4. After validation runs, create your Service Connector. |
| 44 | + |
| 45 | +Your tiles can now be served through your Container App ingress endpoint, e.g. `https://example.name.region.azurecontainerapps.io/tileset/0/0/0.mvt`. |
| 46 | + |
| 47 | +For TileJSON to work, `tileset.json`, re-configure your Container Command Override with the final user-facing URL for your tiles, such as `tiles.example.com`, `my-tiles.azureedge.net` for Microsoft CDN, etc. |
| 48 | + |
| 49 | +## Cost and Latency |
| 50 | + |
| 51 | +* By setting minimum replicas to 0, Azure Container Apps can scale to 0 when there are no requests to be served. However, cold start requests when there are 0 instances can take 10+ seconds to complete. |
| 52 | + |
| 53 | +* Setting minimum replicas to 1 can eliminate cold starts and only incur [idle usage charges](https://azure.microsoft.com/en-us/pricing/details/container-apps/) when running. |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
0 commit comments