Azure deployment - culinary-code/algemeen GitHub Wiki
Azure deployment
This page outlines the efforts we made to deploy the application to Azure. If you also wish to deploy the application to Azure, you can follow this guideline. If you have any questions about this guide or deploying to Azure, please feel free to reach out to us.
Deploying to Azure
Note: For the Azure links you need to have an account on Azure.
GPT
For the deployment of the GPT model, we make use of Azure OpenAI Service. You can set up an OpenAI service on Azure using the following link:
https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI
We used the GPT-4o Mini model for this project. A breakdown of why we chose this model can be found at Recommended LLM Model.
Once the service is set up, you can get the API key and endpoint from the Azure portal and set them as environment variables in the backend application.
Image generator
For recipe image generation, we make use of a DALL-E 3 deployment on Azure. You can set up a DALL-E 3 model deployment on Azure OpenAI Studio.
Once the service is set up, you can get the API key and endpoint from the Azure portal and set them as environment variables in the backend application.
Blob storage
Azure Blob storage is used to store images generated by the DALL-E 3 model. You can set up a Blob storage on Azure using the following link: Microsoft Storage Account
Once the Blob storage is set up, you can get the connection string and container name from the Azure portal and set them as environment variables in the backend application.
Ensure that the MIME type of the images generated by the DALL-E 3 model is set to "image/png" before uploading them to the Blob storage.
Also ensure you configure the CORS settings of the Blob storage to allow requests from the backend application. As well as the public access level of the container to allow public access to the images.
Database
Azure PostgreSQL database - Flexible server
You can set up a PostgreSQL database on Azure using the following link: DB for PostgreSQL Flexible Servers
Configure the specifications based on your development or production needs.
Create a new user role on the database with restricted permissions to use from the backend application.
Keycloak
When you set up Keycloak, you can export the currently configured realm into a json file, check out the documentation around exporting here: Importing and Exporting Realms
Then you can make a Dockerfile where you pull in the base Keycloak image and add your own ENTRYPOINT command where you set up import realm.
FROM quay.io/keycloak/keycloak:25.0.5
RUN mkdir -p /opt/keycloak/data/import
COPY ./realm-export.json /opt/keycloak/data/import
EXPOSE 8080
ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "-v", "start-dev", "--import-realm"]
Then you can build and push the Docker image to Docker hub for example.
docker build -t steffenvochten/culinarycode_idp:latest . # tag latest so you don't have to delete and recreate the container instance on Azure for image changes
docker push steffenvochten/culinarycode_idp:latest
Now on Azure you can set up a Container Instance which will pull and run your Docker image in the cloud.
If you tag your docker image with latest, you can push changes to the image to Docker hub, without having to delete and recreate the Container Instance, since its settings can't be changed.
Set up a Container Instance on Azure using the following link: Container Instance
Backend
To deploy the app on Azure we make use of the Azure App Service.
To create a Web App on Azure, use this link: https://portal.azure.com/#create/Microsoft.WebSite
The runtime stack the backend application uses is .NET 8. The target operating system is Linux.
Once the Web App is set up on Azure, we can push our backend application to this Web App.
First, navigate to the application's root folder, then follow these steps:
cd .\WEBAPI\
dotnet publish -c Release -r linux-x64 --self-contained false -o ./publish
cd .\publish\
zip -r ../culinarycode.zip .
az webapp deployment source config-zip --resource-group rg-stage24-webchefs --name culinarycode --src culinarycode.zip
You can view application logs using this command:
az webapp log tail --name culinarycode --resource-group rg-stage24-webchefs
Finally ensure that all the environment variables are properly set up in the Web App settings on Azure, ensure that you point the environment variables for the database and Keycloak container URLs point to the proper Azure service URLs.