Edit

Share via


Configure Bring Your Own Storage for Profiler and Snapshot Debugger

Important

If you're using Azure Private Link or customer-managed keys with Application Insights, you must configure Bring Your Own Storage (BYOS) to use Application Insights Profiler for .NET or Snapshot Debugger. This article shows you how to set up BYOS.

By default, when you use Application Insights Profiler for .NET or Snapshot Debugger, artifacts generated by your application are uploaded into Azure Storage accounts managed by Microsoft over the public internet. Microsoft controls and covers the cost for:

  • Processing
  • Analysis
  • Encryption-at-rest and lifetime management policies

Bring Your Own Storage (BYOS) is a configuration option that gives you more control over where these artifacts are stored and how they're accessed. When you configure BYOS, you control and cover the cost for encryption-at-rest policies, lifetime management policies, and network access.

BYOS is required in these scenarios:

BYOS is optional but recommended when you want to:

  • Control network access to diagnostic data
  • Use custom encryption-at-rest policies
  • Manage data retention policies for diagnostic artifacts
  • Meet specific compliance or security requirements

Note

Currently, BYOS isn't supported for storing Code Optimizations trace data in Application Insights.

What you'll configure

In this guide, you learn how to:

  • Create and verify prerequisites to ensure your storage account is ready.
  • Grant Diagnostic Services access to your storage account.
  • Link your storage account with your Application Insights resource.

Prerequisites

Before you begin, ensure you have:

  • An Azure subscription with appropriate permissions
  • An existing Application Insights resource
  • A storage account created in the same location as your Application Insights resource
  • One of the following tools installed:

Verify your storage account location

To verify your storage account is in the correct location:

  1. Open the Azure portal.
  2. Navigate to your storage account.
  3. Check the Location field matches your Application Insights resource location.

Important

If you're using Private Link, you must also configure your storage account to allow connection from Trusted Microsoft Services. See Storage network security documentation for details.

Step 1: Grant Diagnostic Services access to your storage account

The Diagnostic Services Trusted Storage Access application needs permission to write data to your storage account.

Assign the Storage Blob Data Contributor role

  1. In the Azure portal, navigate to your storage account.

  2. Select Access control (IAM) from the left menu.

  3. Select Add > Add role assignment.

  4. On the Add role assignment page, configure the following:

    Setting Value
    Role tab Select Storage Blob Data Contributor
    Members tab > Assign access to Select User, group, or service principal
    Members tab > Members Select + Select members
  5. In the Select members pane:

    1. Search for Diagnostic Services Trusted Storage Access.
    2. Select the application from the results.
    3. Select Select.
  6. Select Review + assign.

    Screenshot that shows the role assignment page in the Azure portal.

Verify the role assignment

  1. Stay on the Access control (IAM) page.

  2. Select the Role assignments tab.

  3. Verify Diagnostic Services Trusted Storage Access appears with the Storage Blob Data Contributor role.

    Screenshot that shows the IAM screen after Role assignments.

Tip

If you don't see the application in the list, wait a few minutes and refresh the page. Role assignments can take up to 5 minutes to propagate.

Choose one of the following methods to link your storage account. We recommend using PowerShell or Azure CLI for easier troubleshooting.

Install the Application Insights PowerShell module

  1. Open PowerShell as an administrator.

  2. Install the Application Insights PowerShell extension:

    Install-Module -Name Az.ApplicationInsights -Force
    
  3. If prompted to install from PSGallery, type Y and press Enter.

Sign in to Azure

Sign in with your Azure account:

Connect-AzAccount -Subscription "{subscription_id}"

Replace {subscription_id} with your actual subscription ID.

Tip

To find your subscription ID, run Get-AzSubscription or check the Azure portal under Subscriptions.

For more information, see Connect-AzAccount documentation.

If your Application Insights resource was previously linked to a different storage account, remove that link:

Remove-AzApplicationInsightsLinkedStorageAccount -ResourceGroupName "{resource_group_name}" -Name "{application_insights_name}"

Replace:

  • {resource_group_name} with your resource group name
  • {application_insights_name} with your Application Insights resource name

Example:

Remove-AzApplicationInsightsLinkedStorageAccount -ResourceGroupName "byos-test" -Name "byos-test-westus2-ai"

Note

If no previous storage account is linked, you might see a "not found" message. This is expected and you can proceed.

  1. Get a reference to your storage account:

    $storageAccount = Get-AzStorageAccount -ResourceGroupName "{resource_group_name}" -Name "{storage_account_name}"
    

    Replace:

    • {resource_group_name} with your resource group name
    • {storage_account_name} with your storage account name
  2. Link the storage account to Application Insights:

    New-AzApplicationInsightsLinkedStorageAccount -ResourceGroupName "{resource_group_name}" -Name "{application_insights_name}" -LinkedStorageAccountResourceId $storageAccount.Id
    

    Replace:

    • {resource_group_name} with your resource group name
    • {application_insights_name} with your Application Insights resource name

Complete example:

# Set your values
$resourceGroup = "byos-test"
$storageAccountName = "byosteststoragewestus2"
$appInsightsName = "byos-test-westus2-ai"

# Remove any previous linked storage account (optional)
Remove-AzApplicationInsightsLinkedStorageAccount -ResourceGroupName $resourceGroup -Name $appInsightsName

# Get storage account
$storageAccount = Get-AzStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccountName

# Link to Application Insights
New-AzApplicationInsightsLinkedStorageAccount -ResourceGroupName $resourceGroup -Name $appInsightsName -LinkedStorageAccountResourceId $storageAccount.Id

After running the link command, you should see output similar to:

Id        : /subscriptions/{subscription}/resourcegroups/byos-test/providers/microsoft.insights/components/byos-test-westus2-ai/linkedstorageaccounts/serviceprofiler
Name      : serviceprofiler
Type      : microsoft.insights/components/linkedstorageaccounts
LinkedStorageAccount : /subscriptions/{subscription}/resourceGroups/byos-test/providers/Microsoft.Storage/storageAccounts/byosteststoragewestus2

If you see an error, check that:

  • Your storage account and Application Insights resource are in the same location
  • You granted the Storage Blob Data Contributor role correctly in Step 1
  • You're signed in to the correct subscription

Step 3: Enable the .NET Profiler or Snapshot Debugger

Now that your storage account is linked, enable the diagnostic tools:

  1. In the Azure portal, navigate to your application resource (for example, App Service).

  2. In the left menu, select Application Insights.

  3. On the Application Insights page, locate the Code-level diagnostics section.

  4. Toggle on Application Insights Profiler or Snapshot Debugger as needed.

    Screenshot that shows the code-level diagnostics in the Azure portal.

  5. Select Save at the top of the page.

Verify BYOS is working

After enabling the .NET Profiler or Snapshot Debugger:

  1. Wait 5-10 minutes for data collection to begin.
  2. Navigate to your storage account in the Azure portal.
  3. Select Containers from the left menu.
  4. Verify that new containers have been created for storing artifacts.

If you don't see new containers after 15 minutes, see the Troubleshooting section.

How your storage account is accessed

Understanding how artifacts flow through your storage account can help with troubleshooting:

  1. Agents upload artifacts - Agents running in your virtual machines or Azure App Service upload artifacts (profiles, snapshots, and symbols) to blob containers in your account. This process contacts the .NET Profiler or Snapshot Debugger to obtain a shared access signature token to a new blob in your storage account.

  2. Diagnostic Services process data - The .NET Profiler or Snapshot Debugger analyzes the incoming blob and writes back the analysis results and log files into blob storage. Depending on available compute capacity, this process might occur anytime after upload.

  3. You view the results - When you view Profiler traces or Snapshot Debugger analysis, the service fetches the analysis results from blob storage.

Troubleshooting

For assistance with troubleshooting BYOS, see the dedicated troubleshooting documentation:

Common issues:

  • Storage account not in the same location - Verify your storage account and Application Insights resource are in the same Azure region.
  • Role assignment not propagated - Wait 5-10 minutes after assigning the Storage Blob Data Contributor role before linking your storage account.
  • Private Link not configured - If using Private Link, ensure you configured your storage account to allow Trusted Microsoft Services.

Frequently asked questions

This section provides answers to common questions about configuring BYOS for .NET Profiler and Snapshot Debugger.

If I enabled the .NET Profiler/Snapshot Debugger and BYOS, is my data migrated into my storage account?

No, it won't. Only new data collected after enabling BYOS is stored in your storage account.

Does BYOS work with encryption-at-rest and customer-managed keys?

Yes. To be precise, BYOS is a requirement to have the .NET Profiler/Snapshot Debugger enabled with customer-manager keys.

Does BYOS work in an environment isolated from the internet?

Yes. BYOS is a requirement for isolated network scenarios.

Yes, it's possible.

If I enabled BYOS, can I go back to using Diagnostic Services storage accounts to store my collected data?

Yes, you can. However, we don't currently support data migration from your BYOS to the Diagnostic Services storage accounts.

Yes. You're responsible for all costs related to storage and networking for your BYOS storage account.

Next steps