如何使用PowerShell脚本在App Insights上正确设置持续导出?

问题描述 投票:1回答:1

我正在关注如何在Azure上为AppInsights设置持续导出的Microsoft文档。

我当前的脚本如下所示:

[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

运行脚本并检查门户时,我可以看到它已创建:

enter image description here

问题:

该脚本打开了Request和Exception(由我提供的$ docType参数),但存储位置或存储容器都没有正确设置。我不确定这里发生了什么。

enter image description here

azure azure-storage-blobs azure-powershell appinsights
1个回答
1
投票

这是设计的(即使我不知道为什么,这很奇怪)。

即使您从azure门户手动创建UI的连续导出,也可以看到相同的行为。但它可以工作,数据将被发送到您之前定义的存储容器。

据我所知,您可以使用此PowerShell cmdlet Get-AzApplicationInsightsContinuousExport来检查存储容器/存储位置。

示例powershell代码:

$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

测试结果如下:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.