Open TimNilimaa opened 2 weeks ago
I agree.
To resolve is required to inspect the code and understand that the "telemetry" configuration should be added in the configuration file, under the section "runtime".
The solution is explained Use Application Insight
@TimNilimaa , can you share the runtime section of the config file? specifically the telemetry
section? Looking at the logs seems like an invalid AppInsights connection string.
Related #1925
@abhishekkumams This is my procedure, probably can help you.
I started from the documentation Run In Container
In the sample configuration missing of the telemetry
configuration, explained in the other section, and I have the same result of @TimNilimaa
This is my working configuration of dab-config.json
{
"$schema": "https://github.com/Azure/data-api-builder/releases/latest/download/dab.draft.schema.json",
"data-source": {
"database-type": "mssql",
"connection-string": "MyHandsomeConnectionString"
},
"runtime": {
"telemetry": {
"application-insights": {
"enabled": true,
"connection-string": "InstrumentationKey=......;IngestionEndpoint=https://REGION.in.applicationinsights.azure.com/;LiveEndpoint=https://REGION.livediagnostics.monitor.azure.com/;ApplicationId=...."
}
}
},
"entities": {
}
This configuration worked for the time that I used.
However, according to my analysis, the bug is placed here, line 128 of RuntimeConfigValidator.cs taken from main
branch, at today.
public void ValidateAppInsightsTelemetryConnectionString(RuntimeConfig runtimeConfig)
{
if (runtimeConfig.Runtime!.Telemetry is not null && runtimeConfig.Runtime.Telemetry.ApplicationInsights is not null)
{
ApplicationInsightsOptions applicationInsightsOptions = runtimeConfig.Runtime.Telemetry.ApplicationInsights;
if (applicationInsightsOptions.Enabled && string.IsNullOrWhiteSpace(applicationInsightsOptions.ConnectionString))
{
HandleOrRecordException(new DataApiBuilderException(
message: "Application Insights connection string cannot be null or empty if enabled.",
statusCode: HttpStatusCode.ServiceUnavailable,
subStatusCode: DataApiBuilderException.SubStatusCodes.ConfigValidationError));
}
}
}
So, following the main purpose of this topic, and, using the documented configuration, the IF-cases are passed with success, and, a possible solution can be achieved following 2 possible cases:
Review the initialization of the default values for ApplicationInsightsOptions applicationInsightsOptions
and be compliant with the example, OR,
Keep the code like that but modify the message: "Application Insights connection string cannot be null or empty if enabled.",
with a proper text user-friendly message, such as "The default configuration has the AppInsight telemetry enabled, please refer to the link [PUT THE LINK HERE] to complete the actual configuration"
According to my opinion, the 2nd one is preferable because it is cost-effective and reduce the development effort. Of course, the message can be different from the suggestion of mine.
P.S.: @JerryNixon I am sorry, but I aggregated all the information here.
What happened?
Running latest docker image with the provided example from here https://learn.microsoft.com/en-us/azure/data-api-builder/how-to-run-container Only alteration I made was to the password in the file. { "$schema": "https://github.com/Azure/data-api-builder/releases/latest/download/dab.draft.schema.json", "data-source": { "database-type": "mssql", "connection-string": "Server=host.docker.internal\mssql,1433;Initial Catalog=Library;User Id=sa;Password=;TrustServerCertificate=true;"
},
"entities": {
"book": {
"source": "dbo.Books",
"permissions": [
{
"actions": [
"read"
],
"role": "anonymous"
}
]
}
}
}
Main issue is that the error message is too abstract in that it doesn't say anything useful to the 'end user' on what is the issue with the config file.
Version
1.1.7
What database are you using?
Azure SQL
What hosting model are you using?
Container Apps, Custom Docker host
Which API approach are you accessing DAB through?
REST, GraphQL
Relevant log output
Code of Conduct