Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: DAB CLI .env file not loading #2501

Open
1 task done
jrmurdoch opened this issue Dec 22, 2024 · 2 comments
Open
1 task done

[Bug]: DAB CLI .env file not loading #2501

jrmurdoch opened this issue Dec 22, 2024 · 2 comments
Labels
bug Something isn't working triage issues to be triaged

Comments

@jrmurdoch
Copy link

What happened?

Running the following:

dab start -c "swa-db-connections\staticwebapp.database.config.json"

E:\Software\testapp>dab start -c "swa-db-connections\staticwebapp.database.config.json"
Information: Microsoft.DataApiBuilder 1.3.19
Information: User provided config file: swa-db-connections\staticwebapp.database.config.json
Loading config file from E:\Software\testapp\swa-db-connections\staticwebapp.database.config.json.
Deserialization of the configuration file failed during a post-processing step.
Message:
 Environmental Variable, DATABASE_CONNECTION_STRING, not found.

.env file at path "swa-db-connections.env"

DATABASE_CONNECTION_STRING=<actual connection sting here>
DAB_ENVIRONMENT=Development

config file:

"$schema": "https://github.com/Azure/data-api-builder/releases/latest/download/dab.draft.schema.json",
"data-source": {
  "database-type": "mssql",
  "connection-string": "@env('DATABASE_CONNECTION_STRING')",
  "options": {
    "set-session-context": false
  }

Version

1.3.19

What database are you using?

Azure SQL

What hosting model are you using?

Local (including CLI)

Which API approach are you accessing DAB through?

No response

Relevant log output


Code of Conduct

  • I agree to follow this project's Code of Conduct
@jrmurdoch jrmurdoch added bug Something isn't working triage issues to be triaged labels Dec 22, 2024
@jrmurdoch jrmurdoch changed the title [Bug]: DAB CLI .env file not working [Bug]: DAB CLI .env file not loading Dec 22, 2024
@jrmurdoch
Copy link
Author

I found the error.... the documentation says "Create a file named .env in the same directory as your DAB CLI configuration files."

https://learn.microsoft.com/en-us/azure/data-api-builder/how-to-use-environments#create-environment-variables-file

Although its loaded from the folder where "dab start" is run.

so as above, need to "cd swa-db-connections" then run:

dab start -c "staticwebapp.database.config.json"

then the .env file load correctly.

@JerryNixon
Copy link
Contributor

I think the .env file needs to be in the working folder of the cli when calling it. Meaning if it is in /one you can change directory to /one then run dab start -c /two/config.json. I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage issues to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants