Application Insights Connection String Injection: What App Service Injects vs. What Sends Telemetry¶
Status: Published
Experiment completed with real data on 2026-05-04.
1. Question¶
When APPLICATIONINSIGHTS_CONNECTION_STRING is configured as an App Service application setting, does the Python gunicorn process automatically send request telemetry to Application Insights — or does the developer still need to install and initialize the Azure Monitor SDK explicitly?
2. Why this matters¶
App Service auto-instrumentation for Python is not equivalent to .NET or Java. When a customer adds the Application Insights resource via the portal's "Application Insights" blade (or manually sets the connection string as an app setting), the environment variable is injected into the gunicorn process — but unlike .NET, no agent is attached, no instrumentation happens, and no telemetry is collected. The customer sees the connection string in their environment and assumes it is working. Nothing flows to Application Insights.
3. Customer symptom¶
"I connected Application Insights to my Python App Service but there's no data" or "Live Metrics shows 0 connected instances even though my app is running" or "The connection string is set correctly but Application Insights shows nothing."
4. Hypothesis¶
- H1: Setting
APPINSIGHTS_INSTRUMENTATIONKEYandAPPLICATIONINSIGHTS_CONNECTION_STRINGas app settings causes both values to appear in the gunicorn process environment (os.environ). - H2: Despite the connection string being injected, no telemetry flows to Application Insights without explicit Azure Monitor SDK initialization in the Python application code.
- H3: App Service always injects
ORYX_AI_CONNECTION_STRINGinto the Python process environment — a separate, platform-internal instrumentation key used by the Oryx build system, distinct from the user's Application Insights resource.
5. Environment¶
| Parameter | Value |
|---|---|
| Service | Azure App Service |
| SKU / Plan | B1 |
| Region | Korea Central |
| Runtime | Python 3.11 / gunicorn |
| OS | Linux |
| App name | app-batch-1777849901 |
| Application Insights | ai-lab-batch (Korea Central) |
| Date tested | 2026-05-04 |
6. Variables¶
Experiment type: Observability / Platform behavior
Controlled:
APPINSIGHTS_INSTRUMENTATIONKEYandAPPLICATIONINSIGHTS_CONNECTION_STRINGset viaaz webapp config appsettings set- No
azure-monitor-opentelemetryoropencensus-ext-azurepackage installed in the running app - 5 GET requests sent to the app after env injection
Observed:
- Presence of AI-related variables in
os.environvia the/envendpoint - Presence of platform-injected
ORYX_AI_CONNECTION_STRING - Telemetry row count in Application Insights after traffic generation
7. Instrumentation¶
az monitor app-insights component create— create fresh AI resourceaz webapp config appsettings set— inject keys as app settings- Flask
/envendpoint — returnsos.environas JSON - Application Insights portal — Live Metrics, Search (verify zero collection without SDK)
8. Procedure¶
- Create Application Insights resource (
ai-lab-batch, Korea Central). - Set
APPINSIGHTS_INSTRUMENTATIONKEYandAPPLICATIONINSIGHTS_CONNECTION_STRINGas app settings. - Restart app; call
/envendpoint to verify env injection. - Generate 5 GET requests.
- Check Application Insights portal for traces/requests/dependencies.
- Record
ORYX_AI_CONNECTION_STRINGvalue from/envoutput.
9. Expected signal¶
- H1 confirmed if both
APPINSIGHTS_INSTRUMENTATIONKEYandAPPSETTING_APPINSIGHTS_INSTRUMENTATIONKEYappear inos.environ. - H2 confirmed if Application Insights portal shows zero telemetry rows after traffic.
- H3 confirmed if
ORYX_AI_CONNECTION_STRINGis present with a key different from the user's key.
10. Results¶
Application Insights resource¶
```bash az monitor app-insights component create \ --app ai-lab-batch \ --location koreacentral \ --resource-group rg-lab-appservice-batch \ --query "{key:instrumentationKey,conn:connectionString}"
→ { "key": "11a2593f-5b7e-418a-8385-5da5605d75f1", "conn": "InstrumentationKey=11a2593f-5b7e-418a-8385-5da5605d75f1; IngestionEndpoint=https://koreacentral-0.in.applicationinsights.azure.com/; LiveEndpoint=https://koreacentral.livediagnostics.monitor.azure.com/" }
```text
App settings applied and confirmed¶
```bash az webapp config appsettings set -n app-batch-1777849901 -g rg-lab-appservice-batch \ --settings \ "APPINSIGHTS_INSTRUMENTATIONKEY=11a2593f-..." \ "APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=11a2593f-..."
→ [{"name": "APPINSIGHTS_INSTRUMENTATIONKEY"}, {"name": "APPLICATIONINSIGHTS_CONNECTION_STRING"}]
```text
Environment variables in running process (after restart)¶
```text GET /env
Key Value (truncated) ---- ----- APPINSIGHTS_INSTRUMENTATIONKEY 11a2593f-5b7e-418a-8385-5da5605d75f1 APPLICATIONINSIGHTS_CONNECTION_STRING InstrumentationKey=11a2593f-...;IngestionEndpoint=https://... APPSETTING_APPINSIGHTS_INSTRUMENTATIONKEY 11a2593f-5b7e-418a-8385-5da5605d75f1 APPSETTING_APPLICATIONINSIGHTS_CONNECTION_STRING InstrumentationKey=11a2593f-... ORYX_AI_CONNECTION_STRING InstrumentationKey=4aadba6b-30c8-42db-9b93-024d5c62b887
```text Two distinct instrumentation keys in environment:
| Variable | Key prefix | Source |
|---|---|---|
APPINSIGHTS_INSTRUMENTATIONKEY |
11a2593f |
User-configured app setting |
ORYX_AI_CONNECTION_STRING |
4aadba6b |
Platform-injected by Oryx |
Application Insights portal — after 5 requests¶
```text Live Metrics: 0 connected instances Search (30 min): 0 requests, 0 dependencies, 0 traces
```text
11. Interpretation¶
- Measured: H1 is confirmed. Both
APPINSIGHTS_INSTRUMENTATIONKEYandAPPLICATIONINSIGHTS_CONNECTION_STRINGappear inos.environunder both their raw names and with theAPPSETTING_prefix. The injection works correctly. Measured. - Measured: H2 is confirmed. Zero telemetry rows appeared in Application Insights after 5 requests. The connection string being present in the environment has no effect without SDK code. Measured.
- Observed: H3 is confirmed.
ORYX_AI_CONNECTION_STRING(4aadba6b-...) is always present — this is the Oryx build platform's own internal AI resource. It is not the customer's resource and its presence does not indicate that customer telemetry is being sent. Observed. - Inferred: App Service .NET and Java auto-instrumentation works because the platform injects an agent at startup (the
DOTNET_STARTUP_HOOKSor Java-javaagentmechanism). No equivalent Python agent injection exists. Python requires explicit SDK installation and initialization.
12. What this proves¶
APPLICATIONINSIGHTS_CONNECTION_STRINGIS correctly injected into the Python process environment. Measured.- Connection string injection alone produces no telemetry. Explicit SDK initialization is required. Measured.
ORYX_AI_CONNECTION_STRINGis always present in the Python App Service environment — it is a platform key, not the customer's. Observed.
13. What this does NOT prove¶
- Whether
azure-monitor-opentelemetrywithconfigure_azure_monitor()correctly reads the injected connection string and produces telemetry — not tested here. - Whether auto-instrumentation works for .NET or Java App Service (not in scope; those platforms use agent injection).
- The AI resource's
ai-lab-batchLive Metrics behavior after SDK is installed — not tested.
14. Support takeaway¶
When a Python App Service customer reports no data in Application Insights despite a connection string being configured:
- Confirm the setting is stored:
az webapp config appsettings list -n <app> -g <rg> --query "[?name=='APPLICATIONINSIGHTS_CONNECTION_STRING'].value" -o tsv - Confirm injection: check
/envor Kudu SSH forAPPLICATIONINSIGHTS_CONNECTION_STRINGin the process environment. - If the variable is present but no data appears: the app code is missing SDK initialization. Python does not auto-instrument.
- Fix: add
azure-monitor-opentelemetrytorequirements.txtandfrom azure.monitor.opentelemetry import configure_azure_monitor; configure_azure_monitor()at app startup. - Note:
ORYX_AI_CONNECTION_STRINGin/envoutput is a platform-internal key — customers may confuse this with their own AI resource. Always checkAPPLICATIONINSIGHTS_CONNECTION_STRINGseparately.
15. Reproduction notes¶
```bash
APP="
Create AI resource¶
AI_CONN=$(az monitor app-insights component create \ --app my-ai --location koreacentral --resource-group $RG \ --query "connectionString" -o tsv)
Set as app setting¶
az webapp config appsettings set -n $APP -g $RG \ --settings "APPLICATIONINSIGHTS_CONNECTION_STRING=$AI_CONN"
Restart and verify injection¶
az webapp restart -n $APP -g $RG
sleep 30
curl https://
Expected: APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=...¶
ORYX_AI_CONNECTION_STRING=InstrumentationKey=¶
Generate traffic¶
for i in $(seq 1 5); do curl -s https://
Check AI portal — expect 0 results without SDK¶
To fix: add to requirements.txt:¶
azure-monitor-opentelemetry¶
Add to app startup:¶
from azure.monitor.opentelemetry import configure_azure_monitor¶
configure_azure_monitor()¶
```text