<aclass="url fn n profile-usercard-hover"href="https://social.msdn.microsoft.com/profile/mksunitha"target="_blank">mksunitha</a>
<time> 5/10/2017 8:00:57 AM</time>
<hr/>
<divid="content">This tutorial describes how to get started running Django on <ahref="https://azure.microsoft.com/en-us/services/app-service-web">Azure Web Apps</a> with <ahref="https://azure.microsoft.com/en-us/services/postgresql/">Azure Database for PostgreSQL(Preview)</a>. Web Apps provides limited free hosting and rapid deployment, and you can use Python.
<h2>Before you begin</h2>
<ul></ul>
If you don't have an Azure subscription, create a <ahref="https://azure.microsoft.com/free/?WT.mc_id=A261C142F">free account</a> before you begin.
<h2>Deploy from Marketplace</h2>
This blog post describes how to get started running a Django app with postgresql from Azure marketplace . This marketplace solution creates the following resources : <b>Web Apps on Windows </b> and <b>Azure Database for PostgreSQL (Preview)</b>.
Log in to the <ahref="https://portal.azure.com">Azure Portal</a>.Launch the <ahref="https://portal.azure.com/#create/Django.djangopostgresql">Django + PostgreSQL template</a> in the Azure marketplace to get started.Provide the necessary information for web app and database to be deployed.
<div><span>Enter a unique app name for your </span><span>**Web App Name**</span><span>. This name is used as part of the default DNS name for your app </span><em><app_name>.azurewebsites.net</em><span>, so it needs to be unique across all apps in Azure. You can later map a custom domain name to your app before you expose it to your users </span></div>
</div></td>
</tr>
<tr>
<td>Subscription</td>
<td>Select a <span><strong>Subscription</strong></span><span>. If you have multiple subscriptions, choose the appropriate subscription.</span></td>
</tr>
<tr>
<td>Resource group</td>
<td>
<div>
<div><span>Enter a </span><span><strong>resource group</strong></span><span>. A resource group is a logical container into which Azure resources like web apps, databases that is deployed and managed. You can create a resource group or use an existing one</span></div>
</div></td>
</tr>
<tr>
<td>App Service Plan</td>
<td>
<div>
<divstyle="text-align: left"><span>App Service plans represent the collection of physical resources used to host your apps. Select the </span><span><strong>Location</strong></span><span>and the </span><span><strong>Pricing tier</strong></span><span>. For more information on pricing, see <ahref="https://azure.microsoft.com/pricing/details/app-service"> App service pricing tier</a></span></div>
</div></td>
</tr>
<tr>
<td>Server Name</td>
<td>Enter a postgresql database servername</td>
</tr>
<tr>
<td>Server admin login name</td>
<td><span>Enter a postgresql database administrator username</span></td>
</tr>
<tr>
<td>Server admin password</td>
<td><span>Enter a postgresql database administrator password</span></td>
</tr>
<tr>
<td>Version</td>
<td><span>Azure database for PostgreSQL(Preview) currenlty supports PostgreSQL 9.5 version</span></td>
</tr>
<tr>
<td>Pricing tier</td>
<td><span>Choose Basic or Standard pricing tier. For more information on pricing, see <ahref="https://azure.microsoft.com/pricing/details/postgres/"> App service pricing tier</a></span></td>
</tr>
<tr>
<td>Database Name</td>
<td><span>Enter a database name for your web app</span></td>
</tr>
</tbody>
</table>
You can watch the progress by clicking the bell icon at the top of the portal page while the app is being deployed.
The Django + PostgreSQL template contains the Django framework on top of which you can build your application. You can create an Django app using Kudu.
To access Kudu , select your web app in the portal and click<strong>Advanced Tools-> Go</strong>.<ahref="{{ site.baseurl }}/media/2017/05/django-kudu.png"><imgalt="django-kudu"class="alignnone size-large wp-image-4485"height="192"src="{{ site.baseurl }}/media/2017/05/django-kudu-1024x224.png"width="879"/></a>
Click on<strong>Debug Console</strong> to access the<strong>CMD</strong> prompt. In the console run the following commands under wwwroot folder.
This will create <strong>myapp</strong>folder with starter Django app . For more details in Django app, see <ahref="https://docs.djangoproject.com/en/1.11/intro/tutorial01/">Get started with Django</a>.
You can access the database information within Azure portal by clicking in <b>Application settings -> Connection strings</b>. It is best practice to use App Settings for storing your database information instead of hard coding it in your<em>settings.py</em> file. Create these app settings in Azure portal for your web app.
Use <ahref="https://www.pgadmin.org/">PgAdmin</a> PostgreSQL Client to manage your PostgreSQL server and database remotely.
<h2>Django Poll application sample</h2>
You can deploy your own app via GIT or use this sample <ahref="https://github.com/SunBuild/django-poll">Django-poll application</a>. Fork this sample repository or download to locally to start using the sample. For more information to setup GIT, see <ahref="https://docs.microsoft.com/en-us/azure/app-service-web/app-service-deploy-local-git">Local Git Deployment to Azure App Service</a>.