> ## Documentation Index
> Fetch the complete documentation index at: https://docs-xcor.paloaltonetworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Azure

> Learn how to ingest Azure metrics into Palo Alto Networks Cortex XCOR.

> [!NOTE]
>
> This feature isn't available to all Palo Alto Networks Cortex XCOR users and
> might not be visible in your app. For information about enabling this feature in your
> environment, contact [Cortex XCOR Support](https://docs-xcor.paloaltonetworks.com/support.md).

[Microsoft Azure](https://azure.microsoft.com/) is a public cloud platform. Use the
Microsoft Azure integration to collect
[Azure Monitor platform metrics](https://learn.microsoft.com/en-us/azure/azure-monitor/metrics/data-platform-metrics)
with Palo Alto Networks Cortex XCOR.

## Supported telemetry types

The Microsoft Azure integration supports these telemetry types:

| Logs | Metrics | Traces | Events |
| :-: | :-: | :-: | :-: |
| No | Yes | No | No |

## Create the Azure principal

Configure Azure to let Cortex XCOR collect metrics:

1. Create a dedicated Azure managed identity. Assign the built-in
   [`Reader`](https://learn.microsoft.com/en-us/azure/role-based-access-control/built-in-roles/general#reader)
   role for every subscription you want to collect. As a best practice, use the
   identity only for Cortex XCOR to isolate its Azure API quota usage from other
   workloads.

2. Retrieve the `credential_issuer` and `credential_subject` for your tenant.
   Cortex XCOR displays both values in two places:

   * In the Integrations Hub, select **Azure**. The **Your federated credential
     values** panel on the **Overview** tab lists them as **Issuer** and **Subject**.
   * Click your [profile icon](https://docs-xcor.paloaltonetworks.com/navigate#your-account)
     from the menu bar and select **My Account**. The values are displayed next to
     **Azure Federated Credential Issuer** and **Azure Federated Credential Subject**.

   If neither place displays the values, contact
   [Cortex XCOR Support](https://docs-xcor.paloaltonetworks.com/support.md) to obtain them.

3. Copy the `credential_issuer` and `credential_subject` values exactly into a
   federated identity credential on the managed identity.

4. When creating the Azure principal, grant it access to subscriptions using one of
   the following options:

   * Management group-based: Grant access at the
     [Azure Management Group](https://learn.microsoft.com/en-us/azure/governance/management-groups/overview)
     level. The integration collects subscriptions in each management group that the
     managed identity can access. Changes to management group membership change the
     subscriptions visible to the integration. You can grant the same managed identity
     access to multiple management groups.
   * Subscription-based: Grant access to individual subscriptions. Update the role
     assignments when you add or remove subscriptions. The integration doesn't collect
     subscriptions that the managed identity can't access.

5. Record the `azure_tenant_id` and `identity_client_id` Terraform outputs shown in the
   following examples. Use these values to configure the integration in Cortex XCOR.

### Terraform examples

The following examples show how you can integrate Azure using one of the previously
mentioned methods:

> [tab] Management group
>
> The following Terraform code provides an example of how to create an Azure principal
> and grant it access to the subscriptions within a management group.
>
> ```terraform expandable Terraform example icon="square-terminal" theme={null}
> ################################################################################
> ## Azure Provider
>
> terraform {
>   required_providers {
>     azurerm = {
>       source  = "hashicorp/azurerm"
>       version = "~> 4.0"
>     }
>   }
> }
>
> provider "azurerm" {
>   subscription_id = var.subscription_id
>   features {}
> }
>
> ################################################################################
> ## Terraform Variables
>
> variable "subscription_id" {
>   type        = string
>   description = "Azure subscription ID in which to create resources"
> }
>
> variable "location" {
>   type        = string
>   description = "Location in which to create resources"
>   default     = "eastus"
> }
>
> variable "resource_group_name" {
>   type        = string
>   description = "Name of the existing resource group to create resources in"
> }
>
> variable "management_group_id" {
>   type        = string
>   description = "Management group to be integrated with Cortex XCOR"
>   default     = "production-group"
> }
>
> variable "principal_name" {
>   type        = string
>   description = "Name of the Azure principal managed identity"
>   default     = "cortex-xcor-integration"
> }
>
> variable "credential_issuer" {
>   type        = string
>   description = "Federated identity credential issuer provided by Cortex XCOR"
> }
>
> variable "credential_subject" {
>   type        = string
>   description = "Federated identity credential subject provided by Cortex XCOR"
> }
>
> ################################################################################
> ## Azure Resources
>
> data "azurerm_management_group" "this" {
>   name = var.management_group_id
> }
>
> resource "azurerm_user_assigned_identity" "chronosphere" {
>   name                = var.principal_name
>   location            = var.location
>   resource_group_name = var.resource_group_name
> }
>
> # Assign the principal the Reader role on all subscriptions in the management group.
> resource "azurerm_role_assignment" "chronosphere" {
>   principal_id         = azurerm_user_assigned_identity.chronosphere.principal_id
>   scope                = data.azurerm_management_group.this.id
>   role_definition_name = "Reader"
> }
>
> resource "azurerm_federated_identity_credential" "chronosphere" {
>   name                = var.principal_name
>   issuer              = var.credential_issuer
>   subject             = var.credential_subject
>   resource_group_name = var.resource_group_name
>   parent_id           = azurerm_user_assigned_identity.chronosphere.id
>   audience            = ["api://AzureADTokenExchange"]
> }
>
> ################################################################################
> ## Terraform Outputs
>
> output "azure_tenant_id" {
>   value = azurerm_user_assigned_identity.chronosphere.tenant_id
> }
>
> output "identity_client_id" {
>   value = azurerm_user_assigned_identity.chronosphere.client_id
> }
> ```

> [tab] Individual subscription
>
> The following Terraform code provides an example of how to create an Azure principal
> and grant it access to individual subscriptions. In this example, read access is
> granted to all accessible subscriptions.
>
> ```terraform expandable Terraform example icon="square-terminal" theme={null}
> ################################################################################
> ## Azure Provider
>
> terraform {
>   required_providers {
>     azurerm = {
>       source  = "hashicorp/azurerm"
>       version = "~> 4.0"
>     }
>   }
> }
>
> provider "azurerm" {
>   subscription_id = var.subscription_id
>   features {}
> }
>
> ################################################################################
> ## Terraform Variables
>
> variable "subscription_id" {
>   type        = string
>   description = "Azure subscription ID in which to create resources"
> }
>
> variable "location" {
>   type        = string
>   description = "Location in which to create resources"
>   default     = "eastus"
> }
>
> variable "resource_group_name" {
>   type        = string
>   description = "Name of the existing resource group to create resources in"
> }
>
> variable "principal_name" {
>   type        = string
>   description = "Name of the Azure principal managed identity"
>   default     = "cortex-xcor-integration"
> }
>
> variable "credential_issuer" {
>   type        = string
>   description = "Federated identity credential issuer provided by Cortex XCOR"
> }
>
> variable "credential_subject" {
>   type        = string
>   description = "Federated identity credential subject provided by Cortex XCOR"
> }
>
> ################################################################################
> ## Azure Resources
>
> data "azurerm_subscriptions" "all" {}
>
> resource "azurerm_user_assigned_identity" "chronosphere" {
>   name                = var.principal_name
>   location            = var.location
>   resource_group_name = var.resource_group_name
> }
>
> # Assign the principal the Reader role on each subscription.
> resource "azurerm_role_assignment" "chronosphere" {
>   for_each             = toset(data.azurerm_subscriptions.all.subscriptions[*].id)
>   principal_id         = azurerm_user_assigned_identity.chronosphere.principal_id
>   scope                = each.key
>   role_definition_name = "Reader"
> }
>
> resource "azurerm_federated_identity_credential" "chronosphere" {
>   name                = var.principal_name
>   issuer              = var.credential_issuer
>   subject             = var.credential_subject
>   resource_group_name = var.resource_group_name
>   parent_id           = azurerm_user_assigned_identity.chronosphere.id
>   audience            = ["api://AzureADTokenExchange"]
> }
>
> ################################################################################
> ## Terraform Outputs
>
> output "azure_tenant_id" {
>   value = azurerm_user_assigned_identity.chronosphere.tenant_id
> }
>
> output "identity_client_id" {
>   value = azurerm_user_assigned_identity.chronosphere.client_id
> }
> ```

## Set up Cortex XCOR to receive Azure data

After configuring Azure to enable access to metrics, you must configure
Cortex XCOR to receive and process those metrics.

To access the Cortex XCOR API directly, see the
[Cortex XCOR API for Azure metrics](https://docs-xcor.paloaltonetworks.com/tooling/api-info/definition/operations/ListAzureMetricsIntegrations.md).

### View Azure metrics integrations

To list or view Azure metrics integrations, use one of the following options:

> [tab] Web
>
> In the Cortex XCOR [Integrations Hub](https://docs-xcor.paloaltonetworks.com/integrate/integrations-hub.md),
> select **Microsoft Azure**, then select **Configurations**. Select a configuration to
> view its details.

> [tab] Chronoctl
>
> To list your Azure metrics integrations using [Chronoctl](https://docs-xcor.paloaltonetworks.com/tooling/chronoctl),
> use this command:
>
> ```shell theme={null}
> chronoctl azure-metrics-integrations list
> ```
>
> To view an Azure metrics integration, use this command:
>
> ```shell theme={null}
> chronoctl azure-metrics-integrations read SLUG
> ```
>
> Replace *`SLUG`* with the unique identifier of the Azure metrics integration.

> [tab] API
>
> To list Azure metrics integrations with the Cortex XCOR API, use the
> [`ListAzureMetricsIntegrations`](https://docs-xcor.paloaltonetworks.com/tooling/api-info/definition/operations/ListAzureMetricsIntegrations)
> endpoint.
>
> To view a single Azure metrics integration with the Cortex XCOR API, use
> the [`ReadAzureMetricsIntegration`](https://docs-xcor.paloaltonetworks.com/tooling/api-info/definition/operations/ReadAzureMetricsIntegration)
> endpoint.
>
> Because the Cortex XCOR API requires authentication, include an API token with your
> `curl` request, as shown in the following example. For more details, see
> [Create an API token](https://docs-xcor.paloaltonetworks.com/tooling/api-info.md#create-an-api-token).
>
> ```shell /"TOKEN"/ /INSTANCE/ /METHOD/ /ENDPOINT_PATH/ theme={null}
> export CHRONOSPHERE_API_TOKEN="TOKEN"
> export CHRONOSPHERE_DOMAIN="INSTANCE.chronosphere.io"
>
> curl -H "API-Token: ${CHRONOSPHERE_API_TOKEN}" \
>      -X METHOD "https://${CHRONOSPHERE_DOMAIN}/ENDPOINT_PATH"
> ```
>
> Replace the following:
>
> * *`TOKEN`*: Your API token.
> * *`INSTANCE`*: The subdomain name for your organization's Cortex XCOR instance.
> * *`METHOD`*: The HTTP method to use with the request, such as `GET` or `POST`.
> * *`ENDPOINT_PATH`*: The specific endpoint you want to access.

### Create or update an Azure metrics integration

Create or update an Azure metrics integration using the Integrations Hub, Chronoctl,
Terraform, or the Cortex XCOR API. The Integrations Hub requires the Editor or
SysAdmin role. Chronoctl, Terraform, and the API require the
[SysAdmin](https://docs-xcor.paloaltonetworks.com/administer/accounts-teams/teams.md#add-a-role-to-a-team)
role.

> [tab] Web
>
> In the Cortex XCOR [Integrations Hub](https://docs-xcor.paloaltonetworks.com/integrate/integrations-hub.md),
> select **Microsoft Azure**, then select **Configurations**. Add a configuration or
> select an existing configuration to edit. Enter the managed identity's tenant ID and
> client ID, configure the metrics to collect, and save the configuration.

> [tab] Chronoctl
>
> To create an Azure metrics integration using
> [Chronoctl](https://docs-xcor.paloaltonetworks.com/tooling/chronoctl), use this command:
>
> ```shell theme={null}
> chronoctl azure-metrics-integrations create --filename FILENAME
> ```
>
> Replace *`FILENAME`* with the name of your Chronoctl configuration file.
>
> To update an Azure metrics integration, use this command:
>
> ```shell theme={null}
> chronoctl azure-metrics-integrations update --filename FILENAME
> ```
>
> Replace *`FILENAME`* with the name of your Chronoctl configuration file.
>
> The input file uses the following structure:
>
> ```yaml expandable Chronoctl example icon="square-terminal" theme={null}
> api_version: v1/config
> kind: AzureMetricsIntegration
> spec:
>   name: NAME
>   slug: SLUG
>   principal:
>     tenant_id: TENANT_ID
>     client_id: CLIENT_ID
>   scrape_config:
>     resource_types:
>       - name: RESOURCE_TYPE_NAME
>         metric_names:
>           - METRIC_NAME
>     locations:
>       - LOCATION
>     subscription_ids:
>       - SUBSCRIPTION_ID
>   usage_metrics_enabled: USAGE_METRICS_ENABLED
>   count_metrics_enabled: COUNT_METRICS_ENABLED
>   propagate_tags: PROPAGATE_TAGS
> ```

> [tab] Terraform
>
> To create an Azure integration with
> [Terraform](https://docs-xcor.paloaltonetworks.com/tooling/infrastructure/terraform), use the
> `chronosphere_azure_metrics_integration` resource:
>
> ```terraform expandable Terraform example icon="square-terminal" theme={null}
> resource "chronosphere_azure_metrics_integration" "chronosphere_azure_metrics" {
>   name = "Azure Metrics"
>   slug = "azure-metrics"
>   principal {
>     tenant_id = TENANT_ID
>     client_id = CLIENT_ID
>   }
>   scrape_config {
>     resource_type {
>       name = RESOURCE_TYPE_NAME
>       metric_names = [METRIC_NAME]
>     }
>
>     locations = [LOCATION]
>     subscription_ids = [SUBSCRIPTION_ID]
>   }
>
>   usage_metrics_enabled = USAGE_METRICS_ENABLED
>   count_metrics_enabled = COUNT_METRICS_ENABLED
>   propagate_tags = PROPAGATE_TAGS
> }
> ```

> [tab] API
>
> To create Azure integrations with the Cortex XCOR API, use the
> [`CreateAzureMetricsIntegration`](https://docs-xcor.paloaltonetworks.com/tooling/api-info/definition/operations/CreateAzureMetricsIntegration)
> endpoint.
>
> To update a single Azure integration with the Cortex XCOR API, use
> the [`UpdateAzureMetricsIntegration`](https://docs-xcor.paloaltonetworks.com/tooling/api-info/definition/operations/UpdateAzureMetricsIntegration)
> endpoint.
>
> Because the Cortex XCOR API requires authentication, include an API token with your
> `curl` request, as shown in the following example. For more details, see
> [Create an API token](https://docs-xcor.paloaltonetworks.com/tooling/api-info.md#create-an-api-token).
>
> ```shell /"TOKEN"/ /INSTANCE/ /METHOD/ /ENDPOINT_PATH/ theme={null}
> export CHRONOSPHERE_API_TOKEN="TOKEN"
> export CHRONOSPHERE_DOMAIN="INSTANCE.chronosphere.io"
>
> curl -H "API-Token: ${CHRONOSPHERE_API_TOKEN}" \
>      -X METHOD "https://${CHRONOSPHERE_DOMAIN}/ENDPOINT_PATH"
> ```
>
> Replace the following:
>
> * *`TOKEN`*: Your API token.
> * *`INSTANCE`*: The subdomain name for your organization's Cortex XCOR instance.
> * *`METHOD`*: The HTTP method to use with the request, such as `GET` or `POST`.
> * *`ENDPOINT_PATH`*: The specific endpoint you want to access.

Replace the following:

* *`NAME`*: (string) The name of the Azure integration.
* *`SLUG`*: (string) The unique identifier of the Azure integration.
* *`TENANT_ID`*: (UUID) The ID of the Azure tenant that hosts the managed identity principal.
* *`CLIENT_ID`*: (UUID) The OAuth 2.0 client ID of the managed identity principal.
* *`RESOURCE_TYPE_NAME`*: (string) Name of an Azure resource type.
* *`METRIC_NAME`*: (string) Name of a metric for the resource type. Leave the metric
  list empty to retrieve all metrics.
* *`LOCATION`*: (string) Azure location to collect. Leave the locations list empty to
  retrieve all locations.
* *`SUBSCRIPTION_ID`*: (string) Azure subscription to collect. Leave the subscription
  list empty to retrieve all subscriptions.
* *`USAGE_METRICS_ENABLED`*: (Boolean) Enables collection of Azure usage metrics under
  this principal (`Microsoft.Compute`, `Microsoft.Network`, `Microsoft.Storage`).
* *`COUNT_METRICS_ENABLED`*: (Boolean) Enables Azure count metrics for the configured
  resources.
* *`PROPAGATE_TAGS`*: (Boolean) Specifies whether Azure resource, group, and
  subscription tags should be propagated as metric labels.

### Delete an Azure integration

Delete an Azure integration using one of the following methods:

> [tab] Web
>
> In the Cortex XCOR [Integrations Hub](https://docs-xcor.paloaltonetworks.com/integrate/integrations-hub.md),
> select **Microsoft Azure**, then select **Configurations**. Open the configuration and
> delete it. This action requires the Editor or SysAdmin role.

> [tab] Chronoctl
>
> Your account must have [SysAdmin](https://docs-xcor.paloaltonetworks.com/administer/accounts-teams/teams.md#add-a-role-to-a-team)
> permissions to complete this action.
>
> To delete an Azure integration using
> [Chronoctl](https://docs-xcor.paloaltonetworks.com/tooling/chronoctl), use this command:
>
> ```shell theme={null}
> chronoctl azure-metrics-integrations delete SLUG
> ```
>
> Replace *`SLUG`* with the unique identifier of the Azure metrics integration.

> [tab] API
>
> To complete this action with the Cortex XCOR API, use the
> [`DeleteAzureMetricsIntegration`](https://docs-xcor.paloaltonetworks.com/tooling/api-info/definition/operations/DeleteAzureMetricsIntegration)
> endpoint.
>
> Because the Cortex XCOR API requires authentication, include an API token with your
> `curl` request, as shown in the following example. For more details, see
> [Create an API token](https://docs-xcor.paloaltonetworks.com/tooling/api-info.md#create-an-api-token).
>
> ```shell /"TOKEN"/ /INSTANCE/ /METHOD/ /ENDPOINT_PATH/ theme={null}
> export CHRONOSPHERE_API_TOKEN="TOKEN"
> export CHRONOSPHERE_DOMAIN="INSTANCE.chronosphere.io"
>
> curl -H "API-Token: ${CHRONOSPHERE_API_TOKEN}" \
>      -X METHOD "https://${CHRONOSPHERE_DOMAIN}/ENDPOINT_PATH"
> ```
>
> Replace the following:
>
> * *`TOKEN`*: Your API token.
> * *`INSTANCE`*: The subdomain name for your organization's Cortex XCOR instance.
> * *`METHOD`*: The HTTP method to use with the request, such as `GET` or `POST`.
> * *`ENDPOINT_PATH`*: The specific endpoint you want to access.

## Validate metrics ingestion

After you save the integration, allow time for Azure to publish metrics and for Cortex
XCOR to collect them. In
[Metrics Explorer](https://docs-xcor.paloaltonetworks.com/investigate/querying/metrics/explorer.md),
run:

```text theme={null}
count_over_time({__name__=~"azure_.+"}[30m])
```

A result means that Cortex XCOR received an Azure metric sample in the last 30
minutes. If the query returns no results, confirm that the managed identity can read
the configured subscriptions and that the selected resource types and metrics exist
in those subscriptions.

## Metric information

Cortex XCOR ingests a wide range of Azure metrics. See the
[list of available Azure metrics](https://docs-xcor.paloaltonetworks.com/ingest/xcor/integrations/server/azure/azure-metrics.md).

### Metrics availability

By default, Cortex XCOR waits two minutes before collecting the newest Azure metric
points and uses a minimum two-minute collection interval. A metric's
[Azure time grain](https://learn.microsoft.com/en-us/azure/azure-monitor/metrics/metrics-aggregation-explained#granularity)
or a resource-specific collection setting can increase that interval. Some resources
use collection delays of up to 10 minutes. Additional delay depends on when Azure
publishes each metric.

If a monitor evaluates before its Azure data arrives, use the PromQL
[`offset` modifier](https://prometheus.io/docs/prometheus/latest/querying/basics/#offset-modifier)
to [add offsets to your monitors](https://docs-xcor.paloaltonetworks.com/investigate/alerts/troubleshooting.md#add-offsets-to-your-query).

Points that arrive outside an aggregation rule's late-data buffer can be omitted from
the aggregated metric even when the raw metric point is available.

### Metric semantics

By default, metric names start with `azure_`. The configured metric-name prefix can
change this prefix. Metric names end in `_avg`, `_min`, `_max`, `_count`, or `_total`
to identify the Azure aggregation.

Cortex XCOR converts Azure's **Average**, **Minimum**, and **Maximum** aggregations to
gauges. It converts **Count** and **Total** aggregations to delta counters: each point
represents the value during Azure's aggregation interval, not a cumulative value.
**Total** points can be negative. To total **Count** or **Total** values across a query
window, use `sum_over_time()` instead of `rate()` or `increase()`.

### Metric labels

Standard Azure resource metrics include the `subscription_id`, `resource_group`,
`resource_type`, `resource_name`, and `location` labels. Usage and metadata-derived
metrics can have different label sets. Azure metric dimensions are also converted to
labels.

To add tenant-level custom labels to Azure metrics, contact
[Cortex XCOR Support](https://docs-xcor.paloaltonetworks.com/support.md). These labels are
configured for your deployment rather than on an individual Azure integration. If a
custom label has the same normalized name as an existing metric label, the custom
label value overwrites the existing value.

When **Propagate tags** is enabled, Azure subscription, resource-group, and resource
tags are normalized and added as labels. Resource tags take precedence over
resource-group tags, which take precedence over subscription tags. Propagated tags
also overwrite existing metric and custom labels with the same normalized name. For
example, a propagated Azure tag that normalizes to `location` overwrites the metric's
existing `location` label.

### Find Azure metrics in Metrics Explorer

Use [Metrics Explorer](https://docs-xcor.paloaltonetworks.com/investigate/querying/metrics/explorer.md)
to find and review the status of your ingested metrics.

* By default, Azure metrics start with the prefix `azure_`. Search for the configured
  prefix to display Azure metrics in the platform.

* Search supports substrings. For example, if the original Azure metric name
  contains a substring like `storageAccounts`, searching for the substring returns
  the Azure metric, along with other metrics containing the substring.

## Troubleshooting

The following table lists common problems and how to resolve them:

| Symptom | Resolution |
| - | - |
| The configuration reports that the tenant ID isn't valid. | Copy the directory (tenant) ID from the Azure portal and confirm that the complete value is present. |
| No subscriptions can be read. | Assign the managed identity the `Reader` role on each subscription you want to collect. |
| A configured subscription isn't visible to the integration. | Check the subscription ID for a typo and confirm that the managed identity has the `Reader` role on that subscription. |
| Cortex XCOR can't reach Azure to list subscriptions. | Wait for Azure to respond. Collection resumes automatically. |
| Resource discovery doesn't finish. | Some metrics might be missing for that collection cycle. Cortex XCOR retries discovery automatically. |

## Limitations

* The integration collects Azure Monitor platform metrics. It doesn't collect Azure
  logs or traces.
* The integration can collect only subscriptions and resources visible to the managed
  identity.
* Propagated Azure tags can overwrite another label after label-name normalization.


## Related topics

- [Azure metrics available in Palo Alto Networks Cortex XCOR](https://docs-xcor.paloaltonetworks.com/ingest/xcor/integrations/server/azure/azure-metrics.md)
- [CreateAzureMetricsIntegration](https://docs-xcor.paloaltonetworks.com/tooling/api-info/definition/operations/CreateAzureMetricsIntegration.md)
- [UpdateAzureMetricsIntegration](https://docs-xcor.paloaltonetworks.com/tooling/api-info/definition/operations/UpdateAzureMetricsIntegration.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.