microsoft / navcontainerhelper

Official Microsoft repository for BcContainerHelper, a PowerShell module, which makes it easier to work with Business Central Containers on Docker.
MIT License
379 stars 243 forks source link

Suggestion: Support environment telemetry #1506

Closed RafaelKoch closed 3 years ago

RafaelKoch commented 3 years ago

Describe the issue When using containers it may also be of interest to activate environment telemetry. In real life telemetry is activated in Admin Center for SaaS. For on-premises it is activated either when mounting a tenant or for single-tenant by configuring the ST.
For containers it may get a bit tricky, because at least for multi-tenancy it has to be done when mounting the tenant. So I was wondering if You could support these settings:

Additional context It should work, containers are already successfully sending out extension-level telemetry. So I believe when set up correctly environment-level telemetry will also be emitted. Why is it nice to have? -> When testing development it is already quite useful to analyze performance metrics and troubleshoot those before even going live anywhere.

freddydk commented 3 years ago

You add these parameters:

    -multitenant:$false `
    -additionalParameters @("--env CustomNavSettings=ApplicationInsightsInstrumentationKey=yourkey")

and see that it works. Currently, it doesn't work in multitenancy.

I will add a parameter to new-bccontainer called ApplicationInsightInstrumentationKey used for single tenancy and the default tenant - and I will add the same parameter on new-bccontainertenant to override the key on subsequent tenant creations.

freddydk commented 3 years ago

I have published a new insider generic with support for telemetry. if you create this key in bccontainerhelper.config.json:

{
    "genericImageName": "mcr.microsoft.com/businesscentral:{0}-dev"
}

Then you will use the insider generic image on this machine until you remove it.

You can also do this in code:

$bcContainerHelperConfig.genericImageName = "mcr.microsoft.com/businesscentral:{0}-dev"

after importing the module, then this session uses the insider generic. Note that every task in devops is a new session and you would have to use this line in every PowerShell task.

You could also just add:

   -useGenericImage "$(Get-BestGenericImageName)-dev"

to your new-bccontainer, then this container is created using the new generic image.

In the next containerhelper, you can do this:

New-BcContainer `
    -accept_eula `
    -credential $credential `
    -auth $auth `
    -artifactUrl $artifactUrl `
    -updateHosts `
    -licenseFile $licenseFile `
    -applicationInsightsKey "84bd9223-67d4-1234-5678-9e4a46023be2"

New-BcContainerTenant -tenantId test -applicationInsightsKey "d216f5eb-1111-2222-956d-4d4e1a00b9ff"
New-BcContainerBcUser -tenant test -Credential $credential -PermissionSetId SUPER

The applicationInsightsKey in New-BcContainer is used for single tenancy and/or for the default tenant. When creating new tenants you can specify the same or another key.

Note that all of this is not necessary in order to have telemetry from apps. If you add the app insights key in app.json, then that will work without the new generic and/or containerhelper (see here: https://github.com/microsoft/navcontainerhelper/issues/1514)

freddydk commented 3 years ago

Shipped in https://www.powershellgallery.com/packages/BcContainerHelper/1.0.15-preview278

freddydk commented 3 years ago

Shipped in 1.0.15