Информация о приложении Непрерывный экспорт конфигурации периодически выбрасывает "Несанкционированный"
Мы используем "azure-arm-appinsights:2.1.0" для настройки конфигурации непрерывного экспорта App Insights. Мы делаем эту настройку конфигурации После развертывания шаблона ARM через узел CLI - в рамках развертывания мы генерируем Service SAS для учетной записи хранения.
Мы наблюдаем эту проблему периодически (по крайней мере, один раз в день), и наше развертывание на основе node-cli не удается из-за этой ошибки.
// Create a Continuous Export configuration of an Application Insights component.
protected createAppInsightsComponentExport(deploymentProperties: any): Promise<any> {
const client = new ApplicationInsightsManagementClient(this._credentials, this._subscriptionId);
const resourceGroup = deploymentProperties.outputs.resourceGroup.value;
const appInsightsName = deploymentProperties.outputs.appInsightsName.value;
const exportReq: ApplicationInsightsComponentExportRequest = {
destinationAccountId: deploymentProperties.outputs.logsStorageName.value,
destinationAddress: deploymentProperties.outputs.appInsightsLogsContainerServiceSASUrl.value,
destinationStorageLocationId: deploymentProperties.outputs.resourceGroupLocation.value,
destinationStorageSubscriptionId: deploymentProperties.outputs.subscriptionId.value,
destinationType: 'Blob',
isEnabled: 'true',
recordTypes: 'Requests, Event, Exceptions, Metrics, PageViews, PageViewPerformance, Rdd, PerformanceCounters, Availability, Messages',
};
// Get existing exportConfigurations - update or create accordingly
return client.exportConfigurations.list(resourceGroup, appInsightsName)
.then((exportConfigurations: any) => {
if (exportConfigurations.length > 0) {
// Update the existing exportConfiguration
return client.exportConfigurations.update(resourceGroup, appInsightsName, exportConfigurations[0].exportId, exportReq);
} else {
// exportConfiguration doesn't exist - create new one
return client.exportConfigurations.create(resourceGroup, appInsightsName, exportReq)
.then((configurations: any) => {
return Promise.resolve(configurations[0]);
});
}
})
.then((exportConfiguration: any) => {
if (exportConfiguration.exportStatus.toLowerCase() === 'failure') {
const errorMsg = 'Continuous Export configuration of an Application Insights setup failed: ' +
+ exportConfiguration.permanentErrorReason + '. ExportId:' + exportConfiguration.exportId;
fileLogger.error(errorMsg);
return Promise.reject(new Error(errorMsg));
} else {
return Promise.resolve(exportConfiguration.exportId);
}
})
.catch((error: any) => {
fileLogger.error(error);
return Promise.reject(new Error(
`Failed to setup Continuous Export configuration of an Application Insights: ${error.message || (error.body && error.body.message)}`));
});
}
}
// Service SAS token generation - ARM template
"listServiceSasApiVersion":"2019-04-01",
"listServiceSasRequestContent": {
"canonicalizedResource": "[concat('/blob/', parameters('logsStorageName'), '/', variables('appInsightsLogsContainerName'))]",
"signedResource": "c",
"signedPermission": "rwdl",
"signedExpiry": "2220-05-24T11:32:48.8457197Z",
"signedStart": "2019-05-24T11:32:48.8457197Z"
},
"appInsightsLogsContainerServiceSASUrl": {
"type": "string",
"value": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', parameters('logsStorageName'))).primaryEndpoints.blob, variables('appInsightsLogsContainerName'), '?' , listServiceSas(parameters('logsStorageName'), variables('listServiceSasApiVersion'), variables('listServiceSasRequestContent')).serviceSasToken)]"
},
Трассировка стека исключений:
ERROR D:\a\r1\a\farmbeats-installer-test\publish\deploymentmanager.js:412 { Error: Unauthorized
at client.pipeline (D:\a\r1\a\farmbeats-installer-test\node_modules\azure-arm-appinsights\lib\operations\exportConfigurations.js:114:19)
at retryCallback (D:\a\r1\a\farmbeats-installer-test\node_modules\ms-rest\lib\filters\systemErrorRetryPolicyFilter.js:89:9)
……
statusCode: 401,
request:
{ rawResponse: false,
queryString: {},
url:
'https://management.azure.com/subscriptions/da9*******/resourceGroups/myresoucegroup/providers/Microsoft.Insights/components/AppInsights-d5dco/exportconfiguration?api-version=2015-05-01',
response:
{ body:
'{"code":"Unauthorized","message":"Unauthorized","innererror":{"diagnosticcontext":"91071cb2-4616-4b1a-a87a-ad13f838c3c6","time":"2019-07-29T23:49:40.7101216Z"}}',