Deploying GraphOS Router on Azure
Deploy router with Azure Container App
Learn how to deploy the router for development on Azure as a Container App.
You will:
Build a router image with a Dockerfile.
Set up an Azure Container Registry and push your router image to it.
Create and deploy an Azure Container App for your router.
Prerequisites
Before you start:
Set up a GraphQL API in GraphOS.
Save your
APOLLO_KEY
andAPOLLO_GRAPH_REF
. You'll need them when deploying the router.
Install Docker locally.
Login to or create an Azure account.
Install Azure CLI.
Choose a version of the router to deploy (for example,
v1.61.0
). You'll need it when specifying the router image to deploy.
Build router image
To deploy your own router, start by customizing and building a router image, using a Dockerfile and a router configuration file:
In a local directory, create a
router.yaml
file and copy-paste the following configuration into the file:YAMLrouter.yaml1supergraph: 2 listen: 0.0.0.0:4000 3health_check: 4 listen: 0.0.0.0:8088
The router's default HTTP and health check endpoint addresses are localhost, so they wouldn't be reachable when deployed. This configuration enables the router to listen to all addresses.
Create a
Dockerfile
file and copy-paste the following into the file:Text# Use the official Apollo Router Core image as the base. # Set the image tag to the desired router version (e.g. v1.61.0) FROM ghcr.io/apollographql/router:v1.61.0 # Replace the default router config with the local, customized router.yaml COPY router.yaml /dist/config/router.yaml
The Dockerfile sources the base router image from the GitHub container registry, using the version of router you specify. It then copies your customized
router.yaml
configuration file to overwrite the default router configuration file.From the same local directory, use
docker buildx build
to build a new router image for a specific platform. Choose a name and tag for the image, for examplerouter:v1.61.0
.Bashdocker buildx build --platform linux/amd64 -t router:v1.61.0 --load .
The
--load
option loads the built image todocker images
.
Run
docker images
and validate that your router image is in the returned list of images.
Push router image to container registry
Create an Azure Container Registry as needed, then push your router image to it.
Create new container registry
If you don't have an existing container registry, create a new one:
Log in to the Azure Portal and go to Container registries.
Click Create container registry.
Fill in the details:
Subscription: Select your subscription
Resource group: Select existing group or create new
Registry name: Enter a unique name for your registry (for example,
myapolloregistry
)Location: Select an appropriate region
Pricing plan: Select an appropriate plan
Click Review + create, then click Create.
Your registry should now be created. Click on your registry to go to its portal page.
Log in to container registry
In a terminal, sign in to Azure CLI:
Bashaz login
Log in and authenticate to your registry (for example,
myapolloregistry
):Bashaz acr login --name myapolloregistry
Tag and push image to registry
Use
docker tag
to create an alias of the image with the fully qualified path to your registry (for example,myapolloregistry.azurecr.io
):Bashdocker tag router:v1.61.0 myapolloregistry.azurecr.io/router:v1.61.0
Push the image to the registry:
Bashdocker push myapolloregistry.azurecr.io/router:v1.61.0
Use
az acr repository list
to verify your image is now in the registry:Bashaz acr repository list --name myapolloregistry
Expected output
[
"myapolloregistry"
]
Deploy the router
Create and deploy a container app to run the router in Azure:
Log in to the Azure Portal, then go to Create Container App
Fill in the details for the Basics tab:
Subscription: Select your subscription
Resource Group: Select existing group or create new
Name: Enter a unique name for your web app.
Publish: Choose Container
Operating System: Choose Linux
Region: Select an appropriate region
App Service Plan: Select existing plan or create new
Fill in the details for the Container tab:
Subscription: Select your subscription
Registry: Select your registry
Image: Select your router image
Image tag: Select your router image's tag
Arguments override: Enter
--dev, --config, /dist/config/router.yaml
Environment variables: Enter
APOLLO_GRAPH_REF
andAPOLLO_KEY
with your graph ref and API key, respectively
Fill in the details for the Ingress tab:
Ingress: Check Enabled
Ingress traffic: Select Accepting traffic from anywhere
Ingress type: Select HTTP
Target port: Enter
4000
(must match your router'ssupergraph.listen
port)
Click Review + create.
Click Create, then wait for your deployment to complete.
Click Go to resource to open the portal page for your deployed container, then click on the Application Url to verify that your router's Sandbox is running successfully.
Congrats, you've successfully deployed the router!