Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly set up Continuous Exports on App Insights with powershell script?

I'm following the Microsoft Documentation on how to set up Continuous Exports for AppInsights on Azure.

My current script looks like this:

[CmdletBinding()]
Param(
    [Parameter(Mandatory=$True)]
    [String]$resourceGroupName,

    [Parameter(Mandatory=$True)]
    [String]$appInsightsName,

    [Parameter(Mandatory=$True)]
    [String[]]$docTypes,

    [Parameter(Mandatory=$True)]
    [String]$storageAccountName,

    [Parameter(Mandatory=$True)]
    [String]$continuousExportContainerName

)

Login-AzureSubscription > $Null

$storage = Get-AzureRmStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName
$continuousExportContainer = Get-AzureStorageContainer -Context $storage.Context -Name $continuousExportContainerName
$sasToken = New-AzureStorageContainerSASToken -Name testcontainer -Context $storage.Context -ExpiryTime (Get-Date).AddYears(50) -Permission "rwdl"
$sasUri = $continuousExportContainer.CloudBlobContainer.Uri.AbsoluteUri + $sasToken
$defaultLocation = Get-DataCenterLocation us AppInsights

New-AzureRmApplicationInsightsContinuousExport -ResourceGroupName $resourceGroupName -Name $appInsightsName -DocumentType $docTypes -StorageAccountId $storage.Id -StorageLocation $defaultLocation -StorageSASUri $sasUri

When running the scrip and checking the portal I can see it was created:

enter image description here

The problem:

The script turned on Request and Exception (supplied by me for the $docType parameter) but neither the Storage location or the Storage container were set up properly. I'm not sure what is happening here.

enter image description here

like image 792
Raudel Ravelo Avatar asked Dec 06 '25 06:12

Raudel Ravelo


1 Answers

This is by design(even though I don't know why, it is weird).

Even when you manually create the continuous exports by UI from the azure portal, you can see the same behavior. But it works and data will be sent to the storage container you defined previously.

And as far as I know, you can use this powershell cmdlet Get-AzApplicationInsightsContinuousExport to check the storage container / Storage location.

Sample powershell code:

$s = Get-AzApplicationInsightsContinuousExport -ResourceGroupName your_resourceGroupName -Name your_app_insights_name

# get the storage container name
$s.ContainerName

# get the Storage location name
$s.DestinationStorageLocationId

# get the storage account name
$s.StorageName

Test result as below:

enter image description here

like image 188
Ivan Yang Avatar answered Dec 08 '25 20:12

Ivan Yang