Run these commands in the root folder of the sample app to create an App Service and deploy the code to it.Ĭreate an app service using the az webapp up command. querytext 'create database restaurant 'Ĭreate an Azure App Service and deploy the code For example, you can use the What's My IP Address? website.Ĭreate a database named restaurant using the az postgres flexible-server execute command. Use any tool or website that shows your IP address to substitute in the command. (If you're using the Azure Cloud Shell, you can skip this step.) IP_ADDRESS=Īz postgres flexible-server firewall-rule create \ This rule allows your local environment access to connect to the server. ACCOUNT_EMAIL=$(az ad signed-in-user show -query userPrincipalName -output tsv)ĪCCOUNT_ID=$(az ad signed-in-user show -query id -output tsv)Īz postgres flexible-server ad-admin create \Ĭonfigure a firewall rule on your server with the az postgres flexible-server firewall-rule create command. To list available SKUs, use az postgres flexible-server list-skus -location $LOCATION.Īdd your Azure account as an Azure AD admin for the server with the az postgres flexible-server ad-admin create command. For more information, see Azure Database for PostgreSQL pricing. The sku-name is the name of the pricing tier and compute configuration. Change the line continuation character for other shells.) az postgres flexible-server create \ (This and subsequent commands use the line continuation character for Bash Shell ('\'). Later you create environment variables with these values where the $ character has special meaning within the Linux container used to run Python apps.Ĭreate a PostgreSQL flexible server with the az postgres flexible-server create command. When creating usernames or passwords do not use the $ character. The ADMIN_PW must contain 8 to 128 characters from three of the following categories: English uppercase letters, English lowercase letters, numbers, and nonalphanumeric characters. LOCATION="eastus"ĪPP_SERVICE_NAME="msdocs-mi-web-$RAND_ID"ĭB_SERVER_NAME="msdocs-mi-postgres-$RAND_ID"Īz group create -location $LOCATION -name $RESOURCE_GROUP_NAME Set up the environment variables needed for the tutorial and create a resource group with the az group create command. cd msdocs-django-web-app-managed-identityĬreate an Azure PostgreSQL flexible server Download or clone the sample application to your development environment. Use the sample Django sample application to follow along with this tutorial. You can run the tutorial commands in any environment with the CLI installed, such as your local environment, the Azure Cloud Shell, or GitHub Codespaces. This tutorial shows you how to deploy the Python web app and create Azure resources using the Azure CLI. For more information about best practices of using managed identities, see Managed identity best practice recommendations. User-assigned identities are recommended because they can be used by multiple resources, and their life cycles are decoupled from the resource life cycles with which they're associated. For an example of using a system managed identity, see Create and deploy a Flask Python web app to Azure with managed identity. In this tutorial, you create a user-assigned managed identity and assign it to the App Service so that it can access the database and storage account resources. The DefaultAzureCredential class automatically detects that a managed identity exists for the App Service and uses it to access other Azure resources. The code uses the DefaultAzureCredential class of the Azure Identity client library for Python. The web app uses managed identity (passwordless connections) with Azure role-based access control to access Azure Storage and Azure Database for PostgreSQL - Flexible Server resources. In this tutorial, you deploy a Django web app to Azure App Service.
0 Comments
Leave a Reply. |