microsoft / ApplicationInsights-Profiler-AspNetCore

Application Insights Profiler sample and documentation
MIT License
67 stars 24 forks source link

visual studio and docker-compose not working. #189

Closed AnthonyDewhirst closed 1 year ago

AnthonyDewhirst commented 1 year ago

I created a brand new .net 6 web app and selected enable docker support, I then copied in the latest app insights and configured.

<Project Sdk="Microsoft.NET.Sdk.Web">

    <PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <Nullable>enable</Nullable>
        <ImplicitUsings>enable</ImplicitUsings>
        <UserSecretsId>98a17432-a18a-471c-b956-6cd9f60a0ca3</UserSecretsId>
        <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
        <DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Microsoft.ApplicationInsights.Profiler.AspNetCore" Version="2.5.0" />
        <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
    </ItemGroup>

</Project>
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddApplicationInsightsTelemetry();
builder.Services.AddRazorPages();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error");
    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();

app.UseRouting();

app.UseAuthorization();

app.MapRazorPages();

app.Run();

and (appsettings.development.json):

{
  "DetailedErrors": true,
  "Logging": {
    "LogLevel": {
      "Default": "Information"
    }
  },
  "ApplicationInsights": {
    "InstrumentationKey": "<guid>"
  }
}

I then ran using "docker" - not docker compose The AI telemetry appeared straight away. All was well.

I then used the instructions at https://learn.microsoft.com/en-us/visualstudio/containers/tutorial-multicontainer?view=vs-2022 to ad the docker-compose project.

I then started using "docker-compose". Now the application insights are no longer collected by visual studio.

xiaomi7732 commented 1 year ago

Hi AnthonyDewhirst, it looks like you are looking for information about enabling application insights (not yet the profiler) in your project. Could you please file an issue here: https://github.com/microsoft/ApplicationInsights-dotnet? Tagging TimothyMothra for awareness.

xiaomi7732 commented 1 year ago

I am closing this since it is not actionable for this repo. Feel free to file new issues if/when profiler get into the picture and if there's any trouble.