Here is what we've found after investigation:
- Microsoft says that the target date for having Application Insights in Gov Cloud on Stage is end of Q4 2018 - as of 10/11/2018.
2./3.
It is possible to associate Application Insights located in Dev (Commercial Cloud) with APIM located in Gov Cloud Stage in two ways - either using VSTS pipeline tasks or REST API. It turns out that Azure Portal GUI will still not show any association or show an invalid association after doing that but the end result is it's working.
Method 1 (tested and working)
VSTS task:
task: AzureResourceGroupDeployment@2
VSTS task template:
{
"$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')]"
]
}
]
}
Method 2 (not tested)
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
}
}