Azure Developer CLI (azd) is an open-source tool that accelerates the time it takes for you to get your application from local development environment to Azure. azd provides best practice, developer-friendly commands that map to key stages in your workflow, whether you’re working in the terminal, your editor or integrated development environment (IDE), or CI/CD (continuous integration/continuous deployment). You can use azd with extensible blueprint templates that include everything you need to get an application up and running on Azure. These templates include reusable infrastructure as code assets and proof-of-concept application code that can be replaced with your own app code. You can also create your own template or find one to build upon.
- azure.yaml - A metadata that is used to configure Azure resources for deployment.
- Leveraging azd to accelerates the time it takes for you to get your application from development environment to Azure.
- Bootstrapping and provisioning an initial template for your Azure environment.
- Test and monitor your new Todo application.
- Grant services data plane access to run and debug the ToDo application locally.
- Configure CI/CD using Github Actions.
- Provision cloud resources:
-
Open new terminal: Menu -> Terminal -> New Terminal (or
Ctrl
+Shift
+~
). -
Execute
azd auth login
to authenticate Azure Developer CLI with your Azure Account. -
Provision Azure Resources:
-
Run the
azd up
command:azd up
-
Pick a new environment name in the following format tt-<your-alias>-dev-<location> (for example tt-amhollan-dev-eus2), where location is a short name representing the location where resources will be be provisioned.
Location Short Name eastus2 eus2 eastus eus westeurope weu centralus cus -
Once you are signed-in to Azure, you will be prompted for the following information:
Parameter Description Azure Location
The Azure location where your resources will be deployed. Azure Subscription
The Azure Subscription where your resources will be deployed.
After you provide these values, the
azd up
command:- Creates and configures all necessary Azure resources (
azd provision
), including:- Access policies and roles for your account
- Service-to-service communication with Managed Identities
- Packages and deploys the code (
azd deploy
) - Create a new environment under .azure directory and set it as the default environment
- Refresh environment settings and state that will be populated while provisioning azure resources via main.parameters.json file.
Note: This might take a few minutes and you can monitor the progress in the terminal, or in Azure Portal via the link under Provisioning Azure resources step.
-
-
After provisioning your Azure resources, you can test and monitor your new ToDo application is up and running.
-
Locate the Web UI endpoint via the terminal output or run
azd show
command:# Showing deployed endpoints and environments for apps in this directory. azd show # Showing deployed specific app endpoint azd show | grep "web" | awk '{print $2}'
-
Open the Web UI endpoint in your browser.
-
Create new ToDo lists and items at least three for each, in order to simulate some traffic to the application.
-
Use
azd monitor
command whose parameters launch various Application Insights dashboards. Run any of the following commands in the terminal to monitor your application health:Application Insights dashboard Command Main dashboard azd monitor --overview Live metrics dashboard azd monitor --live Logs dashboard azd monitor --logs
In order to run and debug the ToDo application, you will require data plane access. The template is already configured with the required resources, but you will need to provide your user principal and reprovision the resources.
-
Update azd environment with your user principal id:
# Retrieve your user object id from Azure Entra ID objectId=$(az ad signed-in-user show --query id -o tsv) azd env set AZURE_PRINCIPAL_ID $objectId
Note: this will update your azd environment under .azure/<environmentName>/.env file and will be populated while provisioning azure resources via main.parameters.json file.
-
Reprovision cloud resources:
azd provision
Prerequisite: The following challenge requires a GitHub account.
CI/CD stands for Continuous Integration/Continuous Delivery. It is a software development practice that aims to automate the building, testing, and deployment of code changes. CI/CD helps developers deliver high-quality software faster and more reliably.
GitHub Actions is a feature of GitHub that allows you to create and run workflows for your repository. Workflows are composed of jobs, which are individual steps that can run commands, scripts, or actions. Actions are reusable pieces of code that can perform tasks such as installing dependencies, running tests, or deploying applications. You can use actions from the GitHub Marketplace or create your own.
To use GitHub Actions for CI/CD, you need to create a YAML file in your repository under the .github/workflows directory. This file defines the triggers, jobs, and actions for your workflow. For example, you can trigger a workflow when you push code to a branch, open a pull request, or create a release. You can also specify the environment, secrets, and artifacts for your workflow.
The course content based on azd template that already contains a Github Action workflow file under .github/workflows/azure-dev.yml. This workflow file is configured to run on every push to the main branch and will execute the following steps:
-
To configure the workflow, you need to give GitHub permission to deploy to Azure on your behalf. Authorize GitHub by creating an Azure service principal stored in a GitHub secret named AZURE_CREDENTIALS.
azd pipeline config --provider github
-
Supply the requested GitHub information.
-
When prompted about committing and pushing your local changes to start a new GitHub Actions run, specify y.
-
In the terminal window, view the results of the azd pipeline config command. The azd pipeline config command will output the GitHub repository name for your project.
-
Using your browser, open the GitHub repository for your project.
-
Select Actions tab to see the workflow running.
Note: In case your repository is forked from the original repository the workflow won't be running, and you will need to enable GitHub Actions Workflow first. Once you enabled the workflow you will be able to trigger it manually, and make sure you are selecting your branch and not the main branch.
Name | Description |
---|---|
Azure Developer CLI | Azure Developer CLI (azd) documentation |
Github Marketplace | GitHub Marketplace provides a curated collection of tools, applications, and services that can be integrated seamlessly with GitHub repositories. |
Github - Azure authentication | Set up Azure Login with OpenID Connect authentication |