Setup
create docker image
docker run -d --name windows_vm -p 8006:8006 -p 3389:3389/tcp -p 3389:3389/udp --device=/dev/kvm --cap-add=NET_ADMIN -e VERSION="11" -e RAM_SIZE="4G" -e CPU_CORES="2" --stop-timeout 120 dockurr/windows
RDP into the virtual machine and use powershell
Invoke-WebRequest -Uri "https://builds.dotnet.microsoft.com/dotnet/Sdk/10.0.100/dotnet-sdk-10.0.100-win-x64.exe" -OutFile "$env:TEMP\dotnet-sdk.exe"
Start-Process "$env:TEMP\dotnet-sdk.exe" -ArgumentList "/install /quiet /norestart" -Wait
mkdir C:\metricpoc
cd C:\metricpoc
dotnet new console
Replace program.cs
using System.Net.Http.Json;
var url = args.Length > 0
? args[0]
: "http://localhost:8293";
var metricName = "Custom Metrics|WindowsVmPoc|CSharpSmoke";
var value = Random.Shared.Next(1, 100);
Console.WriteLine($"Target: {url}");
Console.WriteLine($"Sending: {metricName} = {value}");
using var http = new HttpClient
{
BaseAddress = new Uri(url)
};
var payload = new[]
{
new
{
metricName,
aggregatorType = "OBSERVATION",
value
}
};
using var response = await http.PostAsJsonAsync("/api/v1/metrics", payload);
Console.WriteLine($"HTTP {(int)response.StatusCode} {response.StatusCode}");
var responseText = await response.Content.ReadAsStringAsync();
if (!string.IsNullOrWhiteSpace(responseText))
{
Console.WriteLine(responseText);
}
response.EnsureSuccessStatusCode();
Console.WriteLine("Metric submitted.");
Turn off firwall
notepad C:\AppDynamics\bin\MachineAgentService.vmoptions add these at the end
-Dmetric.http.listener=true -Dmetric.http.listener.port=8293 -Dmetric.http.listener.host=0.0.0.0
disable or configure irewall
dotnet run
