A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://learn.microsoft.com/en-us/azure/container-apps/quickstart-code-to-cloud below:

Quickstart: Build and deploy your app from your local filesystem to Azure Container Apps

This article demonstrates how to build and deploy a microservice to Azure Container Apps from local source code using the programming language of your choice. In this quickstart, you create a backend web API service that returns a static collection of music albums.

The following screenshot shows the output from the album API service you deploy.

Prerequisites

To complete this project, you need the following items:

Setup

To sign in to Azure from the CLI, run the following command and follow the prompts to complete the authentication process.

To ensure you're running the latest version of the CLI, run the upgrade command.

Next, install or update the Azure Container Apps extension for the CLI.

az extension add --name containerapp --upgrade --allow-preview true
az extension add --name containerapp --upgrade --allow-preview true

Now that the current extension is installed, register the Microsoft.App and Microsoft.OperationalInsights namespaces.

az provider register --namespace Microsoft.App
az provider register --namespace Microsoft.OperationalInsights
az provider register --namespace Microsoft.App
az provider register --namespace Microsoft.OperationalInsights
Create environment variables

Now that your CLI setup is complete, you can define the environment variables that are used throughout this article.

Define the following variables in your bash shell.

export RESOURCE_GROUP="album-containerapps"
export LOCATION="canadacentral"
export ENVIRONMENT="env-album-containerapps"
export API_NAME="album-api"

Define the following variables in your PowerShell console.

$RESOURCE_GROUP="album-containerapps"
$LOCATION="canadacentral"
$ENVIRONMENT="env-album-containerapps"
$API_NAME="album-api"
Get the sample code

Run the following command to clone the sample application in the language of your choice and change into the project source folder.

git clone https://github.com/azure-samples/containerapps-albumapi-csharp.git
cd containerapps-albumapi-csharp/src
git clone https://github.com/azure-samples/containerapps-albumapi-java.git
cd containerapps-albumapi-java
git clone https://github.com/azure-samples/containerapps-albumapi-javascript.git
cd containerapps-albumapi-javascript/src
git clone https://github.com/azure-samples/containerapps-albumapi-python.git
cd containerapps-albumapi-python/src
git clone https://github.com/azure-samples/containerapps-albumapi-go.git
cd containerapps-albumapi-go/src
Build and deploy the container app

First, run the following command to create the resource group that will contain the resources you create in this quickstart.

az group create --name $RESOURCE_GROUP --location $LOCATION
az group create --name $RESOURCE_GROUP --location $LOCATION

Build and deploy your first container app with the containerapp up command. This command will:

The up command uses the Dockerfile in project folder to build the container image. The EXPOSE instruction in the Dockerfile defines the target port, which is the port used to send ingress traffic to the container.

In the following code example, the . (dot) tells containerapp up to run in the current directory of the project that also contains the Dockerfile.

az containerapp up \
  --name $API_NAME \
  --resource-group $RESOURCE_GROUP \
  --location $LOCATION \
  --environment $ENVIRONMENT \
  --source .
az containerapp up `
    --name $API_NAME `
    --resource-group $RESOURCE_GROUP `
    --location $LOCATION `
    --environment $ENVIRONMENT `
    --source .

Note

If the command returns an error with the message "AADSTS50158: External security challenge not satisfied", run az login --scope https://graph.microsoft.com//.default to log in with the required permissions and then run the az containerapp up command again.

Verify deployment

Locate the container app's URL in the output of the az containerapp up command. Navigate to the URL in your browser. Add /albums to the end of the URL to see the response from the API.

Limits

The maximum size for uploading source code is 200MB. If the upload goes over the limit, error 413 is returned.

Clean up resources

If you're not going to continue on to the Deploy a frontend tutorial, you can remove the Azure resources created during this quickstart with the following command.

Caution

The following command deletes the specified resource group and all resources contained within it. If the group contains resources outside the scope of this quickstart, they are also deleted.

az group delete --name $RESOURCE_GROUP
az group delete --name $RESOURCE_GROUP
Next steps

After completing this quickstart, you can continue to Tutorial: Communication between microservices in Azure Container Apps to learn how to deploy a front end application that calls the API.

Tutorial: Communication between microservices


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4