Azure Developer CLI (azd) is a command-line tool designed to simplify the development and deployment of applications on Azure. It provides a streamlined and consistent workflow for developers, making it easier to build, test, and deploy applications across various Azure services. This section will guide you through using azd for authentication and deploying your application.
To get started with Azure Developer CLI, you need to install the tool on your local machine. The installation process is straightforward and has instructions for various operating systems:
Before you begin deploying your application, you need to authenticate with Azure. The Azure Developer CLI provides a simple command for this:
- Authentication Command:
- Use
azd auth login
to start the authentication process. This command opens a web page where you can enter your Azure credentials. Once authenticated,azd
stores your credentials securely, allowing you to deploy and manage Azure resources without logging in again during the session.
- Use
After successful authentication, you can proceed with deploying your application using Azure Developer CLI. The process is straightforward and involves the following steps:
- Deploy Your Application:
- Use
azd up
to deploy your application. This command performs several actions:- Builds your application: Compiles and prepares your application for deployment.
- Provisions Azure resources: Automatically creates and configures the necessary Azure services based on your project's requirements.
- Output: The command provides a detailed output, including URLs and endpoints, for accessing your deployed application and related resources.
- Use
Once the deployment is complete, you can access the application. Azure Developer CLI also integrates with Azure Monitor and Azure Application Insights, allowing you to monitor the performance and health of your application directly from the command line.
- Test the setup with appropriate code (e.g., using the OpenAI Python SDK).
- Example code
To enable Protect an API in Azure APIM with Entra ID, create App Registration set the AZURE_ENTRA_AUTH
variable to true before running azd up
-
Create App registration follow steps Register an application in Microsoft Entra ID to represent the API
-
Set following AZD variables:
-
Run
azd env set AZURE_ENTRA_AUTH true
-
Run
azd env set AZURE_CLIENT_ID <apd id>
-
Run
azd env set AZURE_TENANT_ID <tenant id>
-
Run
azd env set AZURE_AUDIENCE <app id URI>
-
Run
azd up
For all examples fill in values in .env
file, sample .env.sample
is provided in src
folder