This repository is a template for the Azure Developer CLI (azd) that includes several different APIs:
-
Star Wars API - a read-only API about the Star Wars films
- REST (includes caching demonstration)
- Synthetic GraphQL
-
Todo List API - a read/write API for storing todo lists.
- REST
- GraphQL (pass-through)
Others will be added in the future. For each backend service, the appropriate configuration is added to the Azure API Management instance to handle that API, and logging for the API is handled via Azure App Insights.
The following prerequisites are required to use this application. Please ensure that you have them all installed locally.
- Azure Developer CLI
- .NET SDK 6.0 - for the API backend
The fastest way for you to get this application up and running on Azure is to use the azd up
command. This single command will create and configure all necessary Azure resources - including access policies and roles for your account and service-to-service communication with Managed Identities.
- Open a terminal, create a new empty folder, and change into it.
- Run the following command to initialize the project, provision Azure resources, and deploy the application code.
azd up --template api-management-sample-apis
You will be prompted for the following information:
Environment Name
: This will be used as a prefix for the resource group that will be created to hold all Azure resources. This name should be unique within your Azure subscription.Azure Location
: The Azure location where your resources will be deployed.Azure Subscription
: The Azure Subscription where your resources will be deployed.
NOTE: This may take a while to complete as it executes three commands:
azd init
(initializes environment),azd provision
(provisions Azure resources), andazd deploy
(deploys application code). You will see a progress indicator as it provisions and deploys your application.
When azd up
is complete it will output the URLs for each backend service. You can also access the APIs through a centralized API Management instance.
NOTE:
- The
azd up
command will create Azure resources that will incur costs to your Azure subscription. You can clean up those resources manually via the Azure portal or with theazd down
command.- You can call
azd up
as many times as you like to both provision and deploy your solution, but you only need to provide the--template
parameter the first time you call it to get the code locally. Subsequentazd up
calls do not require the template parameter. If you do provide the parameter, all your local source code will be overwritten if you agree to overwrite when prompted.- You can always create a new environment with
azd env new
.
While most services are available in all regions, you may need to override the location for certain services. The following are supported:
appInsightsLocationName
for Application Insights.staticSitesLocationName
for Static Web Apps.
To override
This application utilizes the following Azure resources:
- Azure API Management.
- Azure App Services.
- Azure SQL.
- Azure Monitor.
- Azure Cache for Redis.
- Static Web Apps.
This template provisions resources to an Azure subscription that you will select upon provisioning them. Please refer to the Pricing calculator for Microsoft Azure and, if needed, update the included Azure resource definitions found in
infra/main.bicep
to suit your needs.
The repo is structured to follow the Azure Developer CLI conventions including:
- Source Code: All application source code is located in the
src
folder. - Infrastructure as Code: All application "infrastructure as code" files are located in the
infra
folder. - Azure Developer Configuration: An
azure.yaml
file located in the root that ties the application source code to the Azure services defined in your "infrastructure as code" files. - VS Code Configuration: All VS Code configuration to run and debug the application is located in the
.vscode
folder.
This template will create infrastructure and deploy code to Azure. If you don't have an Azure Subscription, you can sign up for a free account here. Make sure you have contributor role to the Azure subscription.
The Azure Developer experience includes an Azure Developer CLI VS Code Extension that mirrors all of the Azure Developer CLI commands into the azure.yaml
context menu and command palette options. If you are a VS Code user, then we highly recommend installing this extension for the best experience.
Here's how to install it:
- Click on the "Extensions" tab in VS Code
- Search for "Azure Developer CLI" - authored by Microsoft
- Click "Install"
- Go to the Azure Developer CLI - VS Code Extension page
- Click "Install"
Once the extension is installed, you can press F1
, and type "Azure Developer CLI" to see all of your available options. You can also right click on your project's azure.yaml
file for a list of commands.
At this point, you have a complete application deployed on Azure. But there is much more that the Azure Developer CLI can do. These next steps will introduce you to additional commands that will make creating applications on Azure much easier. Using the Azure Developer CLI, you can setup your pipelines, monitor your application, test and debug locally.
To help with monitoring applications, the Azure Dev CLI provides a monitor
command to help you get to the various Application Insights dashboards.
-
Run the following command to open the "Overview" dashboard:
azd monitor --overview
-
Live Metrics Dashboard
Run the following command to open the "Live Metrics" dashboard:
azd monitor --live
-
Logs Dashboard
Run the following command to open the "Logs" dashboard:
azd monitor --logs
The easiest way to run and debug is to leverage the Azure Developer CLI Visual Studio Code Extension. Refer to this walk-through for more details.
When you are done, you can delete all the Azure resources created with this template by running the following command:
azd down