我正在将应用程序部署到Azure Gov Cloud Stage&Prod。在Dev&QA上,我们使用连接到AppInsights的APIM来收集统计信息并生成警报,但是,Stage Gov Cloud中不提供AppInsights。
在Gov Cloud on Stage上是否有官方的时间表来提供Application Insights?
作为一种解决方法,我们计划在Dev(例如AI-dev)上创建一个Application Insights资源,该资源将与Stage(例如APIM-stage)中的APIM关联。 但是,当我们想要进行关联时,我们进入Azure Portal中的APIM阶段并尝试选择Application Insights资源-没有可用的资源,Dev和QA中的现有AppInsights资源在阶段的APIM中不可见。 是否可以以可见的方式配置舞台?如果是,那怎么办?我们正在寻找建立这种关联的任何方法-手动或自动使用API。
是否可以使用其他解决方法来收集Stage / Prod部署的应用程序/ APIM请求统计信息?最终目标是让请求警报(例如,针对错误请求)适用于Stage / Prod。
答案 0 :(得分:0)
这是我们经过调查后发现的东西:
2./3。
可以通过两种方式将位于Dev(商业云)中的Application Insights与位于Gov Cloud Stage的APIM相关联-使用VSTS管道任务或REST API。事实证明,这样做之后,Azure Portal GUI仍将不显示任何关联或显示无效的关联,但最终结果是它可以正常工作。
方法1(已测试并可以运行)
VSTS任务:
task: AzureResourceGroupDeployment@2
VSTS任务模板:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appinsights-name": {
"type": "string"
},
"instrumentation": {
"type": "string"
},
"apim-name": {
"type": "string"
},
"api-name": {
"type": "string"
}
},
"resources": [
{
"type": "Microsoft.ApiManagement/service/loggers",
"name": "[concat(parameters('apim-name'), '/', parameters('appinsights-name'))]",
"apiVersion": "2018-01-01",
"scale": null,
"properties": {
"loggerType": "applicationInsights",
"description": null,
"credentials": {
"instrumentationKey": "[parameters('instrumentation')]"
},
"isBuffered": true
}
},
{
"type": "Microsoft.ApiManagement/service/apis/diagnostics",
"name": "[concat(parameters('apim-name'), '/', parameters('api-name'), '/', 'applicationinsights')]",
"apiVersion": "2018-01-01",
"scale": null,
"properties": {
"enabled": true
}
},
{
"type": "Microsoft.ApiManagement/service/apis/diagnostics/loggers",
"name": "[concat(parameters('apim-name'), '/', parameters('api-name'), '/', 'applicationinsights', '/',parameters('appinsights-name'))]",
"apiVersion": "2018-01-01",
"scale": null,
"properties": {
"loggerType": "applicationInsights",
"description": null,
"credentials": {
"instrumentationKey": "[parameters('instrumentation')]"
},
"isBuffered": true,
"resourceId": "[parameters('appinsights-name')]"
},
"dependsOn": [
"[resourceId('Microsoft.ApiManagement/service/apis/diagnostics', parameters('apim-name'), parameters('api-name'), 'applicationinsights')]"
]
}
]
}
方法2(未测试)
PUT https://management.usgovcloudapi.net/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{apimServiceName}/loggers/applicationinsights?api-version=2018-01-01 HTTP/1.1
Authorization: Bearer
Content-Type: application/json
{
"properties": {
"loggerType": "applicationinsights",
"description": null,
"isBuffered": true,
"resourceId": null,
"credentials":{
"instrumentationKey":"<ApplicationInsights-InstrumentationKey>"
}
}
}
PUT https://management.usgovcloudapi.net/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{apimServiceName}/diagnostics/applicationinsights?api-version=2018-01-01 HTTP/1.1
Authorization: Bearer
Content-Type: application/json
{
"properties": {
"enabled": true
}
}