# Azure Service Apps

> Monitor Azure Service Apps with logging using OpenTelemetry sidecar container integration with Last9

Source: https://last9.io/docs/integrations/cloud-providers/azure-service-apps/

Use OpenTelemetry to instrument your Azure Service Apps and send logs to Last9.

This guide outlines the steps to setup Azure Service Apps to send logs to Last9 using OpenTelemetry Collector as a sidecar container.

## Prerequisites

Before setting up Azure Service Apps monitoring, ensure you have:

- Azure Service Apps with sidecar container
- Azure File Share
- Last9 account with integration credentials

1. **Configure Environment Variables**

   Set the environment variable `OTEL_SERVICE_NAME` to the service name of the application that is running in the container.

   Enable the necessary logs such as Service specific logs or HTTP logs in Azure Service Apps.

2. **Setup OpenTelemetry Collector Sidecar Container**

   Create a sidecar container with the following configuration:

   - Registry: `index.docker.io`
   - Image: `otel/opentelemetry-collector-contrib:0.118.0`
   - Port: `4318`
   - Command: `--config /otelconfig/config.yaml --feature-gates transform.flatten.logs`

3. **Setup Azure File Share for OpenTelemetry Collector Configuration**

   Create a file share in Azure Storage Account and mount it to the sidecar container at `/otelconfig`.

   Upload the following configuration file to the file share as `config.yaml`.

   The configuration picks up logs from the Azure Service Apps and sends them to Last9 from `/home/LogFiles/*.log`.

   ```yaml
   receivers:
     otlp:
       protocols:
         grpc:
           endpoint: 0.0.0.0:4317
         http:
           endpoint: 0.0.0.0:4318

     # Detailed configuration options can be found at https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/receiver/filelogreceiver
     filelog:
       # File path pattern to read logs from. Update this to the destination from where you want to read logs.
       # Azure Service Apps writes logs to */home/LogFiles/*.log*
       include: [/home/LogFiles/*.log]
       include_file_path: true
       # attributes:
       # A map of key: value pairs to add to the entry's attributes.
       resource:
         # A map of key: value pairs to add to the entry's resource.
         deployment.environment: "deployment-environment"
         service.name: "service-name" # You can use the environment variable `OTEL_SERVICE_NAME` to set this value.
         # Add additional resource attributes as needed.
       retry_on_failure:
         enabled: true

   processors:
     batch:
       timeout: 5s
       send_batch_size: 10000
       send_batch_max_size: 10000
     transform/add_timestamp:
       error_mode: ignore
       flatten_data: true
       log_statements:
         - context: log
           conditions:
             - time_unix_nano == 0
           statements:
             - set(observed_time, Now())
             - set(time_unix_nano, observed_time_unix_nano)
     resourcedetection/azure:
       detectors: [env, azure]
       timeout: 2s
       override: false

   exporters:
     debug:
       verbosity: detailed
     otlp/last9:
       endpoint: "{{ .Logs.WriteURL }}"
       headers:
         "Authorization": "{{ .Logs.AuthValue }}"

   service:
     pipelines:
       logs:
         receivers: [filelog]
         processors: [resourcedetection/azure, transform/add_timestamp, batch]
         exporters: [otlp/last9]
   ```

## Verification

Once the sidecar container is running, the logs will be sent to Last9. You can verify this by checking the [Logs Explorer](https://app.last9.io/logs) in Last9. For debugging, you can look at the logs in the sidecar container.

## Need Help?

If you encounter any issues or have questions:

- Join our [Discord community](https://discord.com/channels/652153247672729619/652153247672729621) for real-time support
- Contact our support team at [support@last9.io](mailto:support@last9.io)
