-
Notifications
You must be signed in to change notification settings - Fork 1
2. Create an App Service and Connect to Github for CI CD
Now that we have our API on GitHub, it is time to create an Azure App Services resource. We have Linux as the App Service OS. Follow the steps below to create the resource.
Step - 1: Search for "App Services" in azure portal. Visit the Azure Portal to create the app services resource. Search the app services on the Azure Portal, and click on one in the Services section.
Step - 2: Fill in the details to create the resource
Step - 3: Fill in the details to create the resource
Step - 4: Resource deployed successfully
Step - 5: Access the deployed resource
Step - 6: Provide the startup command for starting the web server. Now, as we are going to deploy a FastAPI project on app service, we would need a WSGI server like gunicorn.
Azure App Service for Linux with its Oryx build runner when identifies Python web apps run them using Gunicorn, a WSGI server. So your startup script can have the gunicorn command to spin up the FastAPI app with the help of Gunicorn’s worker class uvicorn.workers.UvicornWorker.
We need to specify the startup command, i.e., the command that needs to be run to start your app. Go to the “Configuration” section from the left navigation bar in the App Services dashboard. Then, go to “General Settings” and type the command shown below:
gunicorn -w 2 -k uvicorn.workers.UvicornWorker main:app
This command tells the gunicorn to use uvicorn server and run the main.py file with 2 workers. The -w indicates the number of workers you want to spin up with Gunicorn.
After that, click on the “Save” button.
Step - 7: Connect to GitHub repository
Step - 8: Connect to GitHub repository. Go to the “Deployment Center” section from the left navigation bar. Then, connect your GitHub account and authorize the App Service to access your GitHub repositories. Then, select all the necessary details as shown in the snapshots above. Now, if anything changes in your GitHub repository, Azure will make sure to integrate and deploy it automatically on App Services. This is the main concept of CI/CD pipelines.