File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # This one is required if you are deploying to Azure App Service.
2+ POST_BUILD_COMMAND = python manage.py migrate
3+
14# The following variables are required for the app to run.
25CLIENT_ID = <client id>
36CLIENT_SECRET = <client secret>
Original file line number Diff line number Diff line change @@ -38,6 +38,20 @@ to sign in users and make authenticated calls to the Microsoft Graph API.
3838 You may need to change to a different port to match your redirect_uri setup.
39392 . Now visit http://localhost:5000
4040
41+ ### Deployment
42+
43+ Once you finish testing this web app locally, you can deploy it to your production.
44+ You may choose any web app hosting services you want.
45+ Here we will describe how to deploy it to
46+ [ Azure App Service] ( https://azure.microsoft.com/en-us/products/app-service ) .
47+
48+ * Follow the [ "Quickstart: Deploy a Python (Django or Flask) web app to Azure App Service"] ( https://learn.microsoft.com/en-us/azure/app-service/quickstart-python ) ,
49+ but replace its sample app (which does not do user sign-in) with this web app.
50+
51+ * [ Configure your app's settings] ( https://learn.microsoft.com/en-us/azure/app-service/configure-common?tabs=portal#configure-app-settings )
52+ to define
53+ [ these environment variables] ( https://github.com/Azure-Samples/ms-identity-python-webapp-django/blob/main/.env.sample ) .
54+
4155
4256## Tutorial
4357
Original file line number Diff line number Diff line change 3636# SECURITY WARNING: don't run with debug turned on in production!
3737DEBUG = True
3838
39- ALLOWED_HOSTS = []
39+
40+ if os .getenv ("WEBSITE_HOSTNAME" ): # Settings for Azure App Service,
41+ # See https://learn.microsoft.com/en-us/azure/app-service/configure-language-python#production-settings-for-django-apps
42+ ALLOWED_HOSTS = [os .getenv ("WEBSITE_HOSTNAME" )]
43+
44+ # See https://learn.microsoft.com/en-us/azure/app-service/configure-language-python#detect-https-session
45+ SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO' , 'https' )
46+ USE_X_FORWARDED_HOST = True
47+ else :
48+ ALLOWED_HOSTS = []
4049
4150
4251# Application definition
Original file line number Diff line number Diff line change 88 < h1 > Microsoft Entra ID Django Web App Sample {{version}}</ h1 >
99 < h2 > Welcome {{ user.name }}!</ h2 >
1010
11- {% load static %}
12- < img src ="{% static 'topology.png' %} " alt ="Topology ">
11+ <!-- There is much hussle to get the local static image to show up on App Service.
12+ https://learn.microsoft.com/en-us/azure/app-service/configure-language-python#serve-static-files-for-django-apps
13+ For now, we will use a remote image.
14+ -->
15+ < img src ="https://github.com/Azure-Samples/ms-identity-python-webapp-django/raw/main/static/topology.png " alt ="Topology ">
1316
1417 < ul >
1518 {% if downstream_api %}
You can’t perform that action at this time.
0 commit comments