Configure a pipeline and push updates
In this article, you'll learn how to use the Azure Developer CLI (azd
) to push template changes through a CI/CD pipeline such as GitHub Actions or Azure DevOps. For this example you'll use the React Web App with Node.js API and MongoDB on Azure template, but you can apply the principles you learn in this article to any of the Azure Developer CLI templates.
Note
The azd pipeline config
command is still in beta. Read more about alpha and beta feature support on the feature versioning and release strategy page.
Prerequisites
All azd
templates include a default GitHub Actions and Azure DevOps pipeline configuration file called azure-dev.yml
, which is required to setup CI/CD. This configuration file provisions your Azure resources and deploy your code to the main branch. You can find azure-dev.yml
:
- For GitHub Actions: in the
.github/workflow
directory. - For Azure DevOps: in the
.azdo/pipelines
directory.
To configure a CI/CD pipeline you'll use the azd pipeline config
command, which handles the following tasks:
- Creates and configures a Service Principal for the app on the Azure subscription.
- Steps you through a workflow to create and configure a GitHub repository and commit your project code to it. You can also choose to use an existing GitHub repository.
- Creates a secure connection between Azure and your repository using GitHub secrets.
- Runs the GitHub action when you check in the workflow file.
For more granular control over this process, you can also manually configure a pipeline.
All templates include a default GitHub Actions and Azure DevOps pipeline configuration file called azure-dev.yml
. This configuration file provisions your Azure resources and deploys your code to the main branch. You can find azure-dev.yml
:
- For GitHub Actions: in the
.github/workflow
directory. - For Azure DevOps: in the
.azdo/pipelines
directory.
You can use the configuration file as-is or modify it to suit your needs.
Select your preferred pipeline provider to continue:
Authorize GitHub to deploy to Azure
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
.
Run the following command to create the Azure service principal and configure the pipeline:
azd pipeline config
This command also creates a private GitHub repository and pushes code to the new repo.
Note
By default,
azd pipeline config
uses OpenID Connect (OIDC), called federated credentials. If you'd rather not use OIDC, runazd pipeline config --auth-type client-credentials
.OIDC/federated credentials are not supported for Terraform.
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. Theazd pipeline config
command will output the GitHub repository name for your project.Using your browser, open the GitHub repository for your project.
Select Actions to see the workflow running.
Make and push a code change
In the project's
/src/web/src/layout
directory, openheader.tsx
.Locate the line
<Text variant="xLarge">ToDo</Text>
.Change the literal
ToDo
tomyTodo
.Save the file.
Commit your change. Committing the change starts the GitHub Action pipeline to deploy the update.
Using your browser, open your project's GitHub repository to see both:
- Your commit
- The commit from GitHub Actions being set up.
Select Actions to see the test update reflected in the workflow.
Visit the web frontend URL to inspect the update.
azd
as a GitHub action
Add azd
as a GitHub action. This action will install azd
. To use it, you can add the following to .github\workflows\azure-dev.yml
:
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install azd
uses: Azure/setup-azd@v0.1.0
Clean up resources
When you no longer need the Azure resources created in this article, run the following command:
azd down
Request help
For information on how to file a bug, request help, or propose a new feature for the Azure Developer CLI, please visit the troubleshooting and support page.
Next steps
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for