This tutorial shows you how to add an OpenTelemetry collector as a sidecar container to a Linux custom container app in Azure App Service.
Sidecar containers in App Service let you deploy extra services and features to your Linux apps without tightly coupling them to the built-in or custom main container. The sidecar containers run alongside the main application container in the same App Service plan.
You can add up to nine sidecar containers for each Linux app in App Service. For example, you can add monitoring, logging, configuration, and networking services as sidecar containers. An OpenTelemetry collector sidecar is one example for monitoring.
For bring-your-own-code Linux apps, see Tutorial: Configure a sidecar container for a Linux app in Azure App Service.
PrerequisitesIf you don't have an Azure account, create a free account before you begin.
You can run the commands in this tutorial by using Azure Cloud Shell, an interactive shell you use through your browser to work with Azure services. To use Cloud Shell:
Select the following Launch Cloud Shell button or go to https://shell.azure.com to open Cloud Shell in your browser.
Sign in to Azure if necessary, and make sure you're in the Bash environment of Cloud Shell.
Select Copy in any code block, paste the code into Cloud Shell, and run it.
The azd
commands in this tutorial use the Azure Developer CLI, an open-source tool that accelerates provisioning and deploying app resources on Azure.
To clone the sample repository and create the resources for this tutorial, run the following commands in Cloud Shell. When prompted, select the Azure subscription and Azure region you want to use.
git clone https://github.com/Azure-Samples/app-service-sidecar-tutorial-prereqs
cd app-service-sidecar-tutorial-prereqs
azd env new my-sidecar-env
azd provision
The azd provision
command uses the included templates to create an Azure resource group called my-sidecar-env_group
that contains the following Azure resources:
nginx
image that has the OpenTelemetry module.otel-collector
OpenTelemetry collector image configured to export to Azure Monitor.id-my-sidecar-env_group
.When deployment completes, you should see output similar to the following example:
Success!
APPLICATIONINSIGHTS_CONNECTION_STRING = InstrumentationKey=aaaaaaaa-0b0b-1c1c-2d2d-333333333333;IngestionEndpoint=https://eastus2-3.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus2.livediagnostics.monitor.azure.com/;ApplicationId=00001111-aaaa-2222-bbbb-3333cccc4444
Azure container registry name = acro2lc774l6vjgg
Managed identity resource ID = /subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/my-sidecar-env_group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id-my-sidecar-env_group
Managed identity client ID = 00aa00aa-bb11-cc22-dd33-44ee44ee44ee
Open resource group in the portal: https://portal.azure.com/#@/resource/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/my-sidecar-env_group
Copy and save the value for APPLICATIONINSIGHTS_CONNECTION_STRING
to use later in this tutorial.
Select the link for Open resource group in the portal
to open the provisioned resource group in the Azure portal.
In the resource group in the Azure portal, create a Linux custom container app with sidecar support, and configure the main container.
On the resource group's page in the Azure portal, select Create.
On the Marketplace page, search for web app, select the down arrow next to Create on the Web App tile, and select Web App.
On the Basics tab of the Create Web App page, provide the following information:
azd provision
.
Leave the rest of the settings as they are, and select the Container tab at the top of the page.
On the Container tab, provide the following information:
azd provision
.azd provision
.
Select Review + create, and when validation passes, select Create.
Once the deployment completes, select Go to resource.
On your app's page, open the URL next to Default domain, https://<app-name>.azurewebsites.net
, in a new browser tab to see the default nginx page.
Add a sidecar container to your Linux custom container app.
On the app's page in the Azure portal, select Deployment Center under Deployment in the left navigation menu. The Deployment Center page shows all the containers in the app, currently only the main container.
Select Add > Custom container.
On the Add container pane, complete the following information:
azd provision
.azd provision
.Select Apply.
There are now two containers in the deployment center labeled Main and Sidecar. An app must have one main container and can have multiple sidecar containers.
4. Configure environment variablesIn the sample scenario, the otel-collector
sidecar is configured to export the OpenTelemetry data to Azure Monitor using the connection string as an environment variable. For more information, see the OpenTelemetry configuration file for the otel-collector image.
Configure the environment variable for the container by configuring app settings for the app. App settings are accessible to all the containers in the app.
On the app's page in the Azure portal, select Environment variables under Settings in the left navigation menu.
On the App settings tab of the Environment variables page, select Add.
On the Add/Edit application setting pane, enter the following values:
APPLICATIONINSIGHTS_CONNECTION_STRING
from the output of azd provision
. You can also find this value as Connection String on the Overview page of the resource group's Application Insight resource.Select Apply, then select Apply again, and then select Confirm. The APPLICATIONINSIGHTS_CONNECTION_STRING app setting now appears on the App settings tab.
The otel-collector
sidecar should now export data to Application Insights.
Go to your app in a new browser tab and refresh the page a few times to generate some web requests.
On the resource group page in the Azure portal, select the Application Insights resource. You should now see some data in the default charts on the Application Insights Overview page.
Note
In this common monitoring scenario, Application Insights is just one of the OpenTelemetry targets you can use, such as Jaeger, Prometheus, and Zipkin.
6. Clean up resourcesWhen you no longer need the environment you created for this tutorial, you can delete the resource group, which removes the app service and all related resources. Run the following command in the cloned repository in Cloud Shell.
azd down
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