Code Monkey home page Code Monkey logo

vssnapshotdebugger-docker's Introduction

Visual Studio Snapshot Debugger Docker Images

This repository contains Dockerfiles that demonstrate how to set up the Visual Studio Snapshot Debugger on Docker images.

What is the Visual Studio Snapshot Debugger?

The Visual Studio Snapshot Debugger is a feature of Visual Studio that allows you to take snapshots and to create log statements of in-production ASP.NET Azure applications without interupting them. Please see https://aka.ms/snappoint for more infomration regarding the Visual Studio Snapshot Debugger.

Dockerfiles

The Dockerfiles are organized according to the ASP.NET Core major and minor version, the OS platform, and the platform architecture. For example, the ASP.NET Core 2.2 Alpine 3.8 x64 Dockerfile is located at /2.2/alpine/amd64/Dockerfile. When built, this Dockerfile produces an image with Alpine 3.8 x64 as the base with ASP.NET Core 2.2 Runtime and the latest supported Snapshot Debugger backend package and vsdbg package.

The Dockerfiles do not take a dependency on the Docker build context, thus they can be built without specifying a build context when executing "docker build".

VsDbg Version Compatibility Table

Pseudo-Version Visual Studio Version
vs2017u5 2019

Latest Release

Version: 2.0.31

File Name Description
vssnapshotdebugger-2.0.31-linux-x64.tar.gz For glibc based OS - most common
vssnapshotdebugger-2.0.31-linux-musl-x64.tar.gz For musl based OS, such as Alpine Linux

Additional Information

  • See releases for information about any current or previous release.
  • See checksums for checksum information for individual files in each release.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Developing

  1. Clone this repository to your local machine.
  2. Run init.cmd or init.ps1, found in the root of the repository.

This initialization script installs local Git hooks to automatically run update scripts when commits are made, for example, the CHECKSUMS, README.md, and RELEASES.md files are updated automatically when a change is made to the releases.json file.

Issues

If you have any problems with or questions about this repository, please contact us through a GitHub issue.

Licenses

Usage of the Snapshot Debugger and Visual Studio Debugger distributable files and components are subject to the licensing and terms defined by Visual Studio.

vssnapshotdebugger-docker's People

Contributors

delmyers avatar jander-msft avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar poppastring avatar wiktork avatar williamxiemsft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vssnapshotdebugger-docker's Issues

Refactor Dockerfiles to follow better image creation practices

  • Use multi-stage build to acquire vssnapshotdebugger and vsdbg; avoids needing to install curl, tar, and awk in the final image.
  • Use no caching options (if available) when installing from package manager.
  • Clean up package manager installation within the same run step to avoid extra layer.
  • Add comments to package install steps to explain their need, especially if it is different between .NET versions (e.g. .NET 8+ Alpine needing libintl).

Image files

Why not just add image files with snapshot debugger already installed to the container repo for .Net?

Cannot see snapshot debugger button

Hi All,

Recently in our company we have decided to use Application Insights to log our requests and responses. We would really like to use the new Snapshot Debugger functionality. Unforutnately I cannot make it work in linux containers.

Here are the steps that I have been through:

  • First I have created a base image from your repository like below
FROM microsoft/dotnet:2.2-aspnetcore-runtime-stretch-slim

# Install Visual Studio Snapshot Debugger prerequisites
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        curl libxml2 uuid libunwind8

# Install Visual Studio Snapshot Debugger
ARG VSSNAPSHOTDEBUGGER_VERSION=2.0.8
ARG VSSNAPSHOTDEBUGGER_SHA512=18cc72ca2bdb291fb126b11ec705e270ad11e0b053010afb19d0252d3f2911a02af7496adf89eec883b9183771867b234902db6a02926ad1f0f736cba5e71e77
RUN curl -SL --output vssnapshotdebugger.tar.gz "https://aka.ms/vssnapshotdebugger/release/${VSSNAPSHOTDEBUGGER_VERSION}/vssnapshotdebugger-${VSSNAPSHOTDEBUGGER_VERSION}-linux-x64.tar.gz" \
    && echo "${VSSNAPSHOTDEBUGGER_SHA512}  vssnapshotdebugger.tar.gz" | sha512sum -c - \
    && mkdir -p /diag \
    && mkdir -p /tmp/diag \
    && tar -pzxf vssnapshotdebugger.tar.gz -C /diag \
    && rm vssnapshotdebugger.tar.gz

# Set environment variables to load Visual Studio Snapshot Debugger into .NET Core applications
ENV CORECLR_ENABLE_PROFILING=1
ENV CORECLR_PROFILER={324F817A-7420-4E6D-B3C1-143FBED6D855}
ENV CORECLR_PROFILER_PATH_64=/diag/Instrumentation64/libInstrumentationEngine.so
ENV MicrosoftInstrumentationEngine_Host={CA487940-57D2-10BF-11B2-A3AD5A13CBC0}
ENV MicrosoftInstrumentationEngine_HostPath_64=/diag/Instrumentation64/libMicrosoftExtensionsHost.so
ENV MicrosoftInstrumentationEngine_FileLog=Errors
ENV MicrosoftInstrumentationEngine_FileLogPath=/tmp/diag/log.txt

# Install Visual Studio Debugger script prerequisites
RUN apt-get install -y --no-install-recommends \
        bash unzip

# Install Visual Studio Debugger
# Check the repo's README for version compatibility with Visual Studio
RUN curl -SL --output getvsdbg.sh "https://aka.ms/getvsdbgsh" \
    && bash ./getvsdbg.sh -v vs2017u5 -l /diag/vsdbg \
    && rm getvsdbg.sh

# Remove package lists to save space; can be restored with 'apt-get update'
RUN rm -rf /var/lib/apt/lists/*
  • Then I have dockerized my application using it as a base image. Here is the Dockerfile
FROM TheAboveBaseImage AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/core/sdk:2.2-stretch AS build
WORKDIR /src
COPY ["AppInsightPOCReceiver/AppInsightPOCReceiver.csproj", "AppInsightPOCReceiver/"]
RUN dotnet restore "AppInsightPOCReceiver/AppInsightPOCReceiver.csproj"
COPY . .
WORKDIR "/src/AppInsightPOCReceiver"
RUN dotnet build "AppInsightPOCReceiver.csproj" -c Release -o /app

FROM build AS publish
RUN dotnet publish "AppInsightPOCReceiver.csproj" -c Release -o /app

FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "AppInsightPOCReceiver.dll"]
  • I have added the application insight packages to my application along with Application Insights SDK. I am able to see the requests and responses correctly. The only thing missing is the Snapshot Debugger button. Here are the packages I have:

    <PropertyGroup>
      <TargetFramework>netcoreapp2.2</TargetFramework>
      <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
      <ApplicationInsightsResourceId>My Resource Id</ApplicationInsightsResourceId>
      <ApplicationInsightsAnnotationResourceId>My ApplicationInsightsAnnotationResourceId</ApplicationInsightsAnnotationResourceId>
      <UserSecretsId>My User Secret Id</UserSecretsId>
      <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
    </PropertyGroup>
    
    <ItemGroup>
      <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.7.1" />
      <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.1.0" />
      <PackageReference Include="Microsoft.ApplicationInsights.SnapshotCollector" Version="1.3.5" />
      <PackageReference Include="Microsoft.ApplicationInsights.Web" Version="2.10.0" />
      <PackageReference Include="Microsoft.AspNetCore.App" />
      <PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
      <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.9" />
    </ItemGroup>
    
    <ItemGroup>
      <WCFMetadata Include="Connected Services" />
    </ItemGroup>
    
  • Here is how my Startup.cs looks like

      public class Startup
      {
      	public class MyTelemetryInitializer : ITelemetryInitializer
      	{
      		public void Initialize(ITelemetry telemetry)
      		{
      			if (string.IsNullOrEmpty(telemetry.Context.Cloud.RoleName))
      			{
      				//set custom role name here
      				telemetry.Context.Cloud.RoleName = "AI_POC_RECEIVER_ROLE_NAME";
      				telemetry.Context.Cloud.RoleInstance = "AI_POC_RECEIVER_ROLE_INSTANCE";
      			}
      		}
      	}
    
      	public IConfiguration Configuration { get; }
    
      	public Startup(IConfiguration configuration, IHostingEnvironment env)
      	{
      		this.Configuration = new ConfigurationBuilder()
      			.SetBasePath(env.ContentRootPath)
      			.AddJsonFile("appsettings.json", optional: true)
      			.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
      			.AddEnvironmentVariables()
      			.Build();
      	}
    
      	public void ConfigureServices(IServiceCollection services)
      	{
      		services.AddSingleton<ITelemetryInitializer, MyTelemetryInitializer>();
      		services.AddApplicationInsightsKubernetesEnricher();
    
      		services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
    
      		services.AddSnapshotCollector(configuration =>
      		{
      			IConfigurationSection section = Configuration.GetSection(nameof(SnapshotCollectorConfiguration));
      			if (section.Value != null)
      			{
      				section.Bind(configuration);
      			}
      		});
      	}
    
      	public void Configure(IApplicationBuilder app, IHostingEnvironment env)
      	{
      		if (env.IsDevelopment())
      		{
      			app.UseDeveloperExceptionPage();
      		}
      		else
      		{
      			app.UseHsts();
      		}
    
      		app.UseHttpsRedirection();
      		app.UseMvc();
      	}
      }
    
  • And finally my appsettings.json file

      {
    "Logging": {
      "LogLevel": {
        "Default": "Warning"
      }
    },
    "AllowedHosts": "*",
    "ApplicationInsights": {
      "InstrumentationKey": "My Instrumentation Key"
    }
      }
    

Some information about our environment.

We use Azure Kubernetes Services. I currently have 1 Linux node which hosts my containers. I can make requests and responses which I can see from Application Insights but I do not have Snapshot Debugger button. Neither do I have the text Don't see snapshot? Troubleshoot.

I have also tried with some older versions following the documentation HERE but the result was the same.

Can you tell me what I am doing wrong or at least point me into the right direction?

Any help is appreciated.

Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.