I thought it might be useful for others to run ANSIBLE playbook for Azure on Windows thanks to WSL
I thought it might be useful for others to run ANSIBLE playbook for Azure on Windows thanks to WSL
I decided to writte my first article on “How to deploy a docker image of a Python API in Azure Web App for Container thanks to ACR thanks to Azure Container services” To go a bit further with this API, I also generated a swagger/OpenAPI which described this API”.
To create my Python API, I used the following Python tutorial. This tutorial provide a API to manage user and groups.
Below, I highlight the most important steps in the Python API docker Image creation & config that I used to deploy this solution in Azure.
The Python API described in the tutorial rely on a local DB. As I expected to host my API in Azure, I created my DB direct in Azure and used a PostgreSQL DB.
To protect my DB in Azure, I activated the PostgreSQL Firewall and add my computer local IP address and the Azure Web App Outbound IP Adresses (talk about this point later in this article).
In order to use my Azure PostgreSQL DB hosted in Azure within my Python API, I have first modify the DB settings in the settings.py file (created in the Python tutorial).
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'demotech3db',
'USER': 'postgres@pgdemotech3',
'PASSWORD' : 'xxxxx',
'HOST': 'pgdemotech3.postgres.database.azure.com',
'PORT': '5432',
'OPTIONS': {
'sslmode': 'require',
},
},
In my Python environment, I also added the following Python packages :
Django==2.1.1
djangorestframework==3.8.2
psycopg2-binary==2.7.5
First I’ve following the Python tutorial and created an admin user for my API :
python manage.py createsuperuser --email dovives@example.com --username admin
Then I run the following command to test my API locally :
python.exe manage.py runserver 0.0.0.0:8000
To go a bit further with this Python API, I generated a swagger to describe this API. To do so, I rely on the following tutorial