<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Dominique VIVES</title>
    <description>Repos of my blog with &quot;Github Pages&quot; feature</description>
    <link>https://dovives.github.io/</link>
    <atom:link href="https://dovives.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Mon, 09 Nov 2020 09:45:18 +0000</pubDate>
    <lastBuildDate>Mon, 09 Nov 2020 09:45:18 +0000</lastBuildDate>
    <generator>Jekyll v3.9.0</generator>
    
      <item>
        <title>Step by Step - Test</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#description&quot; id=&quot;markdown-toc-description&quot;&gt;Description&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;description&quot;&gt;Description&lt;/h1&gt;

I thought it might be useful for others to run ANSIBLE playbook for Azure on Windows thanks to WSL

</description>
        <pubDate>Tue, 10 Nov 2020 00:00:00 +0000</pubDate>
        <link>https://dovives.github.io/2020/11/10/run-ansible-playbook-on-Windows-wsl/</link>
        <guid isPermaLink="true">https://dovives.github.io/2020/11/10/run-ansible-playbook-on-Windows-wsl/</guid>
        
        <category>Azure</category>
        
        <category>Cloud</category>
        
        <category>ANSIBLE</category>
        
        <category>InfraAsCode</category>
        
        
        <category>ANSIBLE</category>
        
      </item>
    
      <item>
        <title>Step by Step - Run ANSIBLE Azure Playbook on WSL</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#description&quot; id=&quot;markdown-toc-description&quot;&gt;Description&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;description&quot;&gt;Description&lt;/h1&gt;

I thought it might be useful for others to run ANSIBLE playbook for Azure on Windows thanks to WSL

</description>
        <pubDate>Sat, 10 Nov 2018 00:00:00 +0000</pubDate>
        <link>https://dovives.github.io/2018/11/10/run-ansible-playbook-on-Windows-wsl/</link>
        <guid isPermaLink="true">https://dovives.github.io/2018/11/10/run-ansible-playbook-on-Windows-wsl/</guid>
        
        <category>Azure</category>
        
        <category>Cloud</category>
        
        <category>ANSIBLE</category>
        
        <category>InfraAsCode</category>
        
        
        <category>ANSIBLE</category>
        
      </item>
    
      <item>
        <title>Deploy Python API Docker image in Azure Web App</title>
        <description>&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#description&quot; id=&quot;markdown-toc-description&quot;&gt;Description&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-python-api-configuration-for-azure-postgresql&quot; id=&quot;markdown-toc-the-python-api-configuration-for-azure-postgresql&quot;&gt;The Python API configuration for Azure PostgreSQL&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#azure-postgresql-db--python-config&quot; id=&quot;markdown-toc-azure-postgresql-db--python-config&quot;&gt;Azure PostgreSQL DB &amp;amp; Python config&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#python-config-for-azure-postgresql-db&quot; id=&quot;markdown-toc-python-config-for-azure-postgresql-db&quot;&gt;Python config for Azure PostgreSQL DB&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#test-azure-the-python-api-with-azure-postgresql-db&quot; id=&quot;markdown-toc-test-azure-the-python-api-with-azure-postgresql-db&quot;&gt;Test Azure the Python API with Azure PostgreSQL DB&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#the-swagger-generation--configuration-of-my-python-api&quot; id=&quot;markdown-toc-the-swagger-generation--configuration-of-my-python-api&quot;&gt;The swagger generation &amp;amp; configuration of my Python API&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;description&quot;&gt;Description&lt;/h1&gt;

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”.

&lt;h1 id=&quot;the-python-api-configuration-for-azure-postgresql&quot;&gt;The Python API configuration for Azure PostgreSQL&lt;/h1&gt;

To create my Python API, I used the following &lt;a href=&quot;https://www.django-rest-framework.org/tutorial/quickstart/&quot;&gt;Python tutorial&lt;/a&gt;. This tutorial provide a API to manage user and groups.

&lt;img src=&quot;https://raw.githubusercontent.com/Dovives/dovives.github.io/master/images/Post1/PythonAPI_UI.png.jpg&quot; alt=&quot;Python API UI Demo&quot; /&gt;

Below, I highlight the most important steps in the Python API docker Image creation &amp;amp; config that I used to deploy this solution in Azure.

&lt;h2 id=&quot;azure-postgresql-db--python-config&quot;&gt;Azure PostgreSQL DB &amp;amp; Python config&lt;/h2&gt;

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.

&lt;img src=&quot;https://raw.githubusercontent.com/Dovives/dovives.github.io/master/images/Post1/AzurePostgreSQLConfig.jpg&quot; alt=&quot;Azure PostgreSQL DB Configuration&quot; /&gt;

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).

&lt;img src=&quot;https://raw.githubusercontent.com/Dovives/dovives.github.io/master/images/Post1/AzurePostgreSQLFWConfig.jpg&quot; alt=&quot;Azure PostgreSQL DB Firewall Configuration&quot; /&gt;

&lt;h2 id=&quot;python-config-for-azure-postgresql-db&quot;&gt;Python config for Azure PostgreSQL DB&lt;/h2&gt;

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).

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;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',
        },
    },
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

In my Python environment, I also added the following Python packages :
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    Django==2.1.1
    djangorestframework==3.8.2
    psycopg2-binary==2.7.5
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;test-azure-the-python-api-with-azure-postgresql-db&quot;&gt;Test Azure the Python API with Azure PostgreSQL DB&lt;/h2&gt;

First I’ve following the Python tutorial and created an admin user for my API :

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    python manage.py createsuperuser --email dovives@example.com --username admin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

Then I run the following command to test my API locally :

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;    python.exe  manage.py runserver 0.0.0.0:8000
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;the-swagger-generation--configuration-of-my-python-api&quot;&gt;The swagger generation &amp;amp; configuration of my Python API&lt;/h1&gt;

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 &lt;a href=&quot;https://raw.githubusercontent.com/axnsan12/drf-yasg/#usage&quot;&gt;tutorial&lt;/a&gt;

&lt;img src=&quot;https://raw.githubusercontent.com/Dovives/dovives.github.io/master/images/Post1/PythonAPI_Swagger.jpg&quot; alt=&quot;Python API Swagger screenshot&quot; /&gt;

</description>
        <pubDate>Wed, 10 Oct 2018 00:00:00 +0000</pubDate>
        <link>https://dovives.github.io/2018/10/10/python-api-docker-image-postgreSQL-azure/</link>
        <guid isPermaLink="true">https://dovives.github.io/2018/10/10/python-api-docker-image-postgreSQL-azure/</guid>
        
        <category>Azure</category>
        
        <category>Cloud</category>
        
        <category>Python</category>
        
        <category>Docker</category>
        
        <category>Image</category>
        
        <category>ACR</category>
        
        <category>WAC</category>
        
        <category>DevOps</category>
        
        
        <category>Azure</category>
        
      </item>
    
  </channel>
</rss>
