1
votes

I have a custom Docker image that uses Windows Servercore as base image..

I have written commands in Dockerfile , which will perform a git pull when my docker image is pulled from Azure Container Registry

Git Repository contains Application Insights DLL and a powershell script. Script uses DLL to create a object of Telemetry and pushes a Dummy Data to App Insights using Trackevent(). I have set this file as Entrypoint in my DockerFile.

So When I Run the Instance/Perform a Docker Pull, The Script runs. The Script runs completely(I have written Write-Host at different parts of Script to confirm this) but the Data is not logged into Azure Application Insights.

when i tried to run the script locally , it does Log the Data to App Insights. Am I missing something here?

$eventprops = @{ Name = "Test" };
$jsonevent=ConvertTo-Json $eventprops; 
$client.TrackEvent($jsonevent,$null) 
# $client is a Telemetry object
1
Is run container shutting down immediately after it's finished? If so, you might need to either flush data out to AI manually or wait a bit until its automatically flushedsilent
yes, it does get terminated post script runPramod Mandicha
please add the code how you log to AppInsightssilent
$eventprops = @{ Name = "Test" };$jsonevent=ConvertTo-Json $eventprops; $client.TrackEvent($jsonevent,$null)Pramod Mandicha
$client is a Telemetry objectPramod Mandicha

1 Answers

1
votes

Application Insights usually sends data out in batches only. If your script shuts down directly after the last logging, it might not have sent this out yet. To solve, you can manually flush. Just add at the end:

$client.Flush()

See here for a complete example.