Open MauroVevy opened 5 months ago
Hi @MauroVevy a few things to try:
There looks to be an issue accessing dbo.MG_AnaArt
Cannot obtain Schema for entity MGAnaArt with underlying database object source: dbo.MG_AnaArt due to: Invalid object name 'dbo.MG_AnaArt'.
cnn
is populated.dab start --config "Full_Path_To_Config"
to ensure dab is resolving the correct config filedab start --config "Full_Path_To_Config"
to rule out any issues resolving the environment variable value.If none of the above work please supply logs of those mitigation attempts. there may also be an issue with the db account referenced in the connection string
Downloading the sources and debugging I found the reason.
I have in my computer an environment variable called connectionstring
which contains the connectionstring to an old database.
In the methods public static ITelemetryChannel? CustomTelemetryChannel { get; set; }
of file
data-api-builder\src\Service\Startup.cs
there is this code:
string configFileName = Configuration.GetValue<string>("ConfigFileName") ?? FileSystemRuntimeConfigLoader.DEFAULT_CONFIG_FILE_NAME;
string? connectionString = Configuration.GetValue<string?>(
FileSystemRuntimeConfigLoader.RUNTIME_ENV_CONNECTION_STRING.Replace(FileSystemRuntimeConfigLoader.ENVIRONMENT_PREFIX, ""),
null);
Where the variable RUNTIME_ENV_CONNECTION_STRING
is equal to DAB_CONNSTRING
and
FileSystemRuntimeConfigLoader.ENVIRONMENT_PREFIX
is equal to DAB_
The result of Replace is CONNSTRING
the value of variable that contains the connection string to the wrong database.
In my opinion there are two errors:
dab-config.json
file, dab
takes the connection string present in the environment variable.set this environment variable
set connstring=Server=myserver; Database=MY_WRONG_DATABASE; Trusted_Connection=True; Integrated Security=true; TrustServerCertificate=true;
Create a dab-config.json like this:
{
"$schema": "https://github.com/Azure/data-api-builder/releases/download/v1.1.7/dab.draft.schema.json",
"data-source": {
"database-type": "mssql",
"connection-string": "Server=myserver; Database=MY_CORRECT_DATABASE; Trusted_Connection=True; Integrated Security=true; TrustServerCertificate=true;",
"options": {
"set-session-context": false
}
},
run dab start
dab
in this way search the schema
on MY_WRONG_DATABASE
@seantleonard
It would be precious if DAB could write the Server
and Database
names when starting.
This way:
Thanks
I'm trying to start dab with this configuration
where the user used in the connection string is a SQL user. Running the dab from one computer starts fine, however when running on another PC with the same user and password the error shown in the "Relevant log output" section appears
Using the sql profiler, we saw that there is no query to the database when run with
dab start
. If instead thedab validate
command is used, dab correctly accesses the database (activity is always displayed via profiler) and dab detects, for example, the triggers present on the table as per the outputVersion
1.1.7
What database are you using?
Azure SQL
What hosting model are you using?
No response
Which API approach are you accessing DAB through?
GraphQL
Relevant log output
Code of Conduct