Skip to content

Commit c3d6b3c

Browse files
authored
Merge pull request #212 from xiaomi7732/dev/saars/use-connection-string
Dev/saars/use connection string
2 parents 6b72e8f + 2b066bf commit c3d6b3c

22 files changed

Lines changed: 591 additions & 45 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,15 @@ public IEnumerable<WeatherForecast> Get()
8787
}
8888
```
8989

90-
* Setup the instrumentation key for debugging
90+
* Setup the connection string for debugging
9191

9292
In [appsettings.Development.json](examples/QuickStart3_0/appsettings.Development.json), add the following configuration:
9393

9494
```jsonc
9595
{
9696
...
9797
"ApplicationInsights": {
98-
"InstrumentationKey": "replace-with-your-instrumentation-key"
98+
"ConnectionString": "replace-with-your-connection-string"
9999
}
100100
...
101101
}

ReleaseNote.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ Profiling the application and the services and monitoring the performance by usi
7171

7272
* Enable button in Profiler Configuration pane does not work
7373

74-
**If you host your app using App Services Linux, you do not need to enable Profiler again in the Performance pane in App Insights portal. Including NuGet package in project and setting App Insights iKey in App Settings are sufficient to enable Profiler**
74+
**If you host your app using App Services Linux, you do not need to enable Profiler again in the Performance pane in App Insights portal. Including NuGet package in project and setting App Insights Connection String in App Settings are sufficient to enable Profiler**
7575
If you follow the [App Insights Profiler for Windows](https://docs.microsoft.com/azure/application-insights/app-insights-profiler) enablement workflow to click **Enable** in the Configure Profiler pane, you will receive an error as the button will try to install the Windows version of profiler agent on Linux environment.
7676
We are working on resolving this issue in the enablement experience.
7777

examples/EnableServiceProfilerCLR2_1/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ RUN dotnet publish -c Release -o out
1313
# Build runtime image
1414
FROM microsoft/dotnet:2.1-aspnetcore-runtime
1515

16-
# Create an argument to allow docker builder to passing in application insights key.
17-
# For example: docker build . --build-arg APPINSIGHTS_KEY=YOUR_APPLICATIONINSIGHTS_INSTRUMENTATION_KEY
18-
ARG APPINSIGHTS_KEY
16+
# Create an argument to allow docker builder to passing in application insights connection string.
17+
# For example: docker build . --build-arg APPINSIGHTS_CONN=<YOUR_APPLICATIONINSIGHTS_CONNECTION_STRING>
18+
ARG APPINSIGHTS_CONN
1919
# Making sure the argument is set. Fail the build of the container otherwise.
20-
RUN test -n "$APPINSIGHTS_KEY"
20+
RUN test -n "$APPINSIGHTS_CONN"
2121

2222
# Light up Application Insights and Service Profiler
23-
ENV APPINSIGHTS_INSTRUMENTATIONKEY $APPINSIGHTS_KEY
24-
ENV ASPNETCORE_HOSTINGSTARTUPASSEMBLIES Microsoft.ApplicationInsights.Profiler.AspNetCore
23+
ENV APPLICATIONINSIGHTS_CONNECTION_STRING=$APPINSIGHTS_CONN
24+
ENV ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=Microsoft.ApplicationInsights.Profiler.AspNetCore
2525

2626
WORKDIR /app
2727
COPY --from=build-env /app/out .

examples/EnableServiceProfilerCLR2_1/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,23 +51,23 @@ To enable Service Profiler, NuGet package needs to be installed and proper envir
5151
# Adding a reference to hosting startup package
5252
RUN dotnet add package Microsoft.ApplicationInsights.Profiler.AspNetCore -v 1.1.7-*
5353
...
54-
# Light up Application Insights for Kubernetes
55-
ENV APPINSIGHTS_INSTRUMENTATIONKEY YOUR_APPLICATION_INSIGHTS_KEY
56-
ENV ASPNETCORE_HOSTINGSTARTUPASSEMBLIES Microsoft.ApplicationInsights.Profiler.AspNetCore
54+
# Light up Application Insights Profiler
55+
ENV APPLICATIONINSIGHTS_CONNECTION_STRING=YOUR_APPLICATION_INSIGHTS_CONNECTION_STRING
56+
ENV ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=Microsoft.ApplicationInsights.Profiler.AspNetCore
5757
...
5858
```
5959

6060
* The first line adds the reference to the NuGet package of Service Profiler before the build of the project happens.
61-
* The second line sets the instrumentation key to Application Insights so that the application knows where to send the trace to.
61+
* The second line sets the connection string to Application Insights so that the application knows where to send the trace to.
6262
* The third line sets the boot strapper for Service Profiler.
6363

6464
*To make your build context as small as possible add a [.dockerignore](.dockerignore) file to your project folder.*
6565

66-
Reference the full [Dockerfile](./Dockerfile), you will notice it is a bit different. The major change is that **YOUR_APPLICATION_INSIGHTS_KEY** has been pulled out to become an argument - the main consideration is for the code security.
66+
Reference the full [Dockerfile](./Dockerfile), you will notice it is a bit different. The major change is that **YOUR_APPLICATION_INSIGHTS_CONNECTION_STRING** has been pulled out to become an argument - the main consideration is for the code security.
6767

6868
## Create an Application Insights resource
6969

70-
Follow the [Create an Application Insights resource](https://docs.microsoft.com/en-us/azure/application-insights/app-insights-create-new-resource). Note down the [instrumentation key](https://docs.microsoft.com/en-us/azure/application-insights/app-insights-create-new-resource#copy-the-instrumentation-key).
70+
Follow the [Create an Application Insights resource](https://docs.microsoft.com/en-us/azure/application-insights/app-insights-create-new-resource). Note down the [connection string](https://learn.microsoft.com/en-us/azure/azure-monitor/app/migrate-from-instrumentation-keys-to-connection-strings#migrate-from-application-insights-instrumentation-keys-to-connection-strings).
7171

7272
## Optionally set the log level to Information for Service Profiler
7373

@@ -85,11 +85,11 @@ Just like in [appsettings.json](./appsettings.json).
8585
## Build and run the Docker image
8686

8787
```shell
88-
docker build -t appinsights-profiler-example --build-arg APPINSIGHTS_KEY=YOUR_APPLICATION_INSIGHTS_KEY .
88+
docker build -t appinsights-profiler-example --build-arg APPINSIGHTS_CONN=YOUR_APPLICATION_INSIGHTS_CONNECTION_STRING .
8989
docker run -p 8080:80 --name appinsights-profiler-example appinsights-profiler-example
9090
```
9191

92-
Note, replace **YOUR_APPLICATION_INSIGHTS_KEY** with the real instrumentation key from the previous step.
92+
Note, replace **YOUR_APPLICATION_INSIGHTS_CONNECTION_STRING** with the real connection string from the previous step.
9393

9494
Once the container starts to run, the Service Profiler will kick in for 2 minutes.
9595

examples/EnableServiceProfilerForContainerApp/Dockerfile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ RUN dotnet publish -c Release -o out
1313
# Build runtime image
1414
FROM mcr.microsoft.com/dotnet/aspnet:3.1
1515

16-
# Create an argument to allow docker builder to passing in application insights key.
17-
# For example: docker build . --build-arg APPINSIGHTS_KEY=YOUR_APPLICATIONINSIGHTS_INSTRUMENTATION_KEY
18-
ARG APPINSIGHTS_KEY
16+
# Create an argument to allow docker builder to passing in application insights conneection string.
17+
# For example: docker build . --build-arg APPINSIGHTS_CONN=YOUR_APPLICATIONINSIGHTS_CONNECTION_STRING
18+
ARG APPINSIGHTS_CONN
1919
# Making sure the argument is set. Fail the build of the container otherwise.
20-
RUN test -n "$APPINSIGHTS_KEY"
20+
RUN test -n "$APPINSIGHTS_CONN"
2121

2222
# Light up Application Insights and Service Profiler
23-
ENV APPINSIGHTS_INSTRUMENTATIONKEY $APPINSIGHTS_KEY
24-
ENV ASPNETCORE_HOSTINGSTARTUPASSEMBLIES Microsoft.ApplicationInsights.Profiler.AspNetCore
23+
ENV APPLICATIONINSIGHTS_CONNECTION_STRING=$APPINSIGHTS_CONN
24+
ENV ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=Microsoft.ApplicationInsights.Profiler.AspNetCore
2525

2626
WORKDIR /app
2727
COPY --from=build-env /app/out .

examples/EnableServiceProfilerForContainerApp/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ _Tips: find the official images for [sdk](https://hub.docker.com/_/microsoft-dot
3636
To enable Service Profiler, NuGet package needs to be installed and proper environment variables need to be set. One way to reach the goal is adding the following lines to your [Dockerfile](./Dockerfile). In this file:
3737

3838
* It adds the reference to the NuGet package of Service Profiler before the build of the project happens.
39-
* It sets the instrumentation key to Application Insights so that the application knows where to send the trace to.
39+
* It sets the connection string to Application Insights so that the application knows where to send the trace to.
4040
* It uses the hosting startup assembly for the entry point of Service Profiler.
4141

4242
*To make your build context as small as possible add a [.dockerignore](./.dockerignore) file to your project folder.*
4343

4444
## Create an Application Insights resource
4545

46-
Follow the [Create an Application Insights resource](https://docs.microsoft.com/en-us/azure/application-insights/app-insights-create-new-resource). Note down the [instrumentation key](https://docs.microsoft.com/en-us/azure/application-insights/app-insights-create-new-resource#copy-the-instrumentation-key).
46+
Follow the [Create an Application Insights resource](https://docs.microsoft.com/en-us/azure/application-insights/app-insights-create-new-resource). Note down the [instrumentation connection string](https://docs.microsoft.com/en-us/azure/application-insights/app-insights-create-new-resource#copy-the-instrumentation-key).
4747

4848
## Optionally set the log level to Information for Service Profiler
4949

@@ -61,11 +61,11 @@ Just like in [appsettings.json](./appsettings.json).
6161
## Build and run the Docker image
6262

6363
```shell
64-
docker build -t enable-sp-example --build-arg APPINSIGHTS_KEY=YOUR_APPLICATION_INSIGHTS_KEY .
64+
docker build -t enable-sp-example --build-arg APPINSIGHTS_CONN="YOUR_APPLICATION_INSIGHTS_CONNECTION_STRING" .
6565
docker run -p 8080:80 --name enable-sp enable-sp-example
6666
```
6767

68-
Note, replace **YOUR_APPLICATION_INSIGHTS_KEY** with the real instrumentation key from the previous step.
68+
Note, replace **YOUR_APPLICATION_INSIGHTS_CONNECTION_STRING** with the real connection string from the previous step.
6969

7070
Once the container starts to run, the Service Profiler will kick in for 2 minutes.
7171

examples/EnableServiceProfilerForContainerAppNet6/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ In this article, you'll learn the various ways you can:
1515

1616
## Pre-requisites
1717

18-
- [An Application Insights resource](https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-new-resource). Make note of the instrumentation key.
18+
- [An Application Insights resource](https://docs.microsoft.com/en-us/azure/azure-monitor/app/create-new-resource). Make note of the connection string.
1919
- [.NET 6 SDK](https://dot.net) for creating projects and local build.
2020
- [Docker Desktop](https://www.docker.com/products/docker-desktop/) to build docker images.
2121

examples/EnableServiceProfilerInVS/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ Follow the wizard to configure the App Service:
8282

8383
```
8484
ASPNETCORE_HOSTINGSTARTUPASSEMBLIES=Microsoft.ApplicationInsights.Profiler.AspNetCore
85-
APPINSIGHTS_INSTRUMENTATIONKEY=0f1b2415-9a4f-4da1-9d26-replacewithyourown
85+
APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=08055218-1dcc-your-own;IngestionEndpoint=someurls-from-application-insights-resource"
8686
```
8787
It will looks like this:
8888

8989
![Set Environment Variables](./.media/SetEnvInPortal.png)
9090

91-
**Note**: The setting of the Application Insights instrumentation key should be optional. However, we have a bug in Service Profiler that requires it to be available for now.
91+
**Note**: The setting of the Application Insights connection string should be optional. However, we have a bug in Service Profiler that requires it to be available for now.
9292

9393
Restart your app, the Service Profiler will be turned on and gathering trace for 2 minutes. Try to generate some traffic to your app during that period. If everything is hooked up correctly, you will start to see the traces after 5 to 10 minutes just like when you see the traces in the debug session.
9494

examples/EnableServiceProfilerInVSCLR2_1/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@ Follow the wizard to configure the App Service:
9797
## Add Settings for the App Service in the Azure Portal
9898

9999
```shell
100-
APPINSIGHTS_INSTRUMENTATIONKEY=0f1b2415-9a4f-4da1-9d26-replacewithyourown
100+
APPLICATIONINSIGHTS_CONNECTION_STRING="InstrumentationKey=08055218-1dcc-48b1-8a67-f449406001c7;IngestionEndpoint=https://westus2-1.in.applicationinsights.azure.com/;LiveEndpoint=https://westus2.livediagnostics.monitor.azure.com/"
101101
```
102102

103103
It will looks like this:
104104

105105
![Set Environment Variables](./.media/SetEnvInPortal.png)
106106

107-
**Note**: The setting of the Application Insights instrumentation key should be optional. However, we have a bug in Service Profiler that requires it to be available for now.
107+
**Note**: The setting of the Application Insights connection string should be optional. However, we have a bug in Service Profiler that requires it to be available for now.
108108

109109
Restart your app, the Service Profiler will be turned on and gathering trace for 2 minutes. Try to generate some traffic to your app during that period. If everything is hooked up correctly, you will start to see the traces after 5 to 10 minutes just like when you see the traces in the debug session.
110110

0 commit comments

Comments
 (0)