{"id":2432,"date":"2023-09-20T12:00:00","date_gmt":"2023-09-20T19:00:00","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/azure-sql\/?p=2432"},"modified":"2026-02-23T11:37:57","modified_gmt":"2026-02-23T19:37:57","slug":"dab-envfiles","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/azure-sql\/dab-envfiles\/","title":{"rendered":"Data API builder Now Supports ENV Files"},"content":{"rendered":"<h2>Data API Builder Supports ENV Files<\/h2>\n<p>One of the reasons developers like you love Data API Builder is because it&#8217;s packed with developer-friendly features. Each feature makes your development journey easier. In earlier versions, we integrated Swagger for easy REST endpoint testing and Banana Cake Pop for simple GraphQL endpoint testing. In this release, we&#8217;ve added ENV file support, enabling you to easily set process-scoped environment variables while developing your API. Node.js developers are accustomed to ENV files, as are Python developers. Data API Builder now accommodates your existing workflow. And, since DAB is language-agnostic, ENV file support works for GO, .NET developers, and everyone else.<\/p>\n<h2>Configuration Primer<\/h2>\n<p>Data API Builder uses a JSON configuration file to direct where your data resides and what objects to expose; you don&#8217;t code for DAB. Setting configuration values is as straightforward as embedding them in the configuration file. But who wants your connections or other pivotal settings hardcoded? Nobody. The answer is environment variables. Fortunately, Data API Builder supports these right out of the box with the <code>@env('my-var-name')<\/code> syntax.<\/p>\n<p><strong>Upgrade your configuration from this:<\/strong><\/p>\n<pre><code class=\"language-JSON\">{\n  \"connection-string\": \"My connection string has secrets!\"\n}<\/code><\/pre>\n<p><strong>To something modular like this:<\/strong><\/p>\n<pre><code class=\"language-JSON\">{\n  \"connection-string\": \"@env('my-connection-string')\"\n}<\/code><\/pre>\n<p>Environment variables shield secrets from plain text exposure and allow for value swapping in different settings. However, these variables must be set either in the <code>user<\/code> or <code>computer<\/code> scope, which can lead to cross-project variable &#8220;bleeding&#8221; if variable names are duplicated. The better alternative? ENV files.<\/p>\n<h2>Enter ENV Files<\/h2>\n<p>Your Git repository likely already has a <code>.gitignore<\/code> file, used to identify files that should not be tracked. Similarly, ENV files have no name\u2014only the <code>.env<\/code> extension. Their internal structure is elegantly simple, defining each variable as <code>name=value<\/code>.<\/p>\n<p><strong>Sample ENV file<\/strong><\/p>\n<pre><code class=\"language-text\"># this is a comment\nenvironment=development\nmy-connection-string=\"Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;\"<\/code><\/pre>\n<blockquote><p>Note that <code>environment<\/code> doesn&#8217;t use quotes, while <code>my-connection-string<\/code> does. Why? The latter&#8217;s value contains <code>=<\/code> equal signs, which are reserved characters.<\/p><\/blockquote>\n<p><em>It really is this simple.<\/em><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-content\/uploads\/sites\/56\/2023\/09\/explorer.png\" alt=\"File Explorer\" \/><\/p>\n<p>To leverage the above <code>.env<\/code> file, simply update your configuration file as previously discussed, wrapping values in <code>@env()<\/code> syntax. Then save your values in your <code>.env<\/code> file. Easy.<\/p>\n<pre><code class=\"language-JSON\">{\n  \"environment\": \"@env('environment')\",\n  \"connection-string\": \"@env('my-connection-string')\"\n}<\/code><\/pre>\n<p>Wherever you employ a scalar value in your Data API Builder configuration file, the <code>@env()<\/code> syntax will replace it with the corresponding environment variable. If a <code>.env<\/code> file is in the same folder as your configuration file, Data API Builder will automatically add those variables to the <code>process<\/code> scope, thus eliminating your risk of &#8220;bleeding&#8221; values into other projects.<\/p>\n<h2>Word of Warning<\/h2>\n<p>One crucial detail to remember: always exclude <code>.env<\/code> files from Git tracking. This means <code>.env<\/code> should always be an entry in your <code>.gitignore<\/code> file. This is important to get right <em>before<\/em> you push to GitHub.<\/p>\n<p><strong>Here&#8217;s the <code>.gitignore<\/code> syntax:<\/strong><\/p>\n<pre><code class=\"language-txt\">.env<\/code><\/pre>\n<p>What&#8217;s the takeaway? ENV files are awesome and their syntax is simple. Data API Builder continues to add features aimed at elevating your development experience. Our current focus is on structured logging and increased OpenAPI version 3 support for REST endpoints. The backlog is deep and &#8211; since we are open-source &#8211; we welcome your contributions, submit a <code>PR<\/code>! Today, however, we celebrate the availability of ENV file support, designed to make environment variable management more streamlined and safe.<\/p>\n<p>Best of luck!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In September, Data API builder (DAB) revved with some great new features. In this article we\u2019ll talk about controlling environment variables with ENV files. What is Data API builder? DAB is an open source, cross-platform engine that creates instant REST &amp; GraphQL APIs for your database &#8211; MySQL, Postgres, Cosmos DB or Microsoft SQL. Without any code, DAB uses only a JSON configuration file that explains how to access your data and what objects to expose.<\/p>\n","protected":false},"author":96788,"featured_media":81,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,597],"tags":[581],"class_list":["post-2432","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure-sql","category-data-api-builder-2","tag-dab"],"acf":[],"blog_post_summary":"<p>In September, Data API builder (DAB) revved with some great new features. In this article we\u2019ll talk about controlling environment variables with ENV files. What is Data API builder? DAB is an open source, cross-platform engine that creates instant REST &amp; GraphQL APIs for your database &#8211; MySQL, Postgres, Cosmos DB or Microsoft SQL. Without any code, DAB uses only a JSON configuration file that explains how to access your data and what objects to expose.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/2432","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/users\/96788"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/comments?post=2432"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/posts\/2432\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media\/81"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/media?parent=2432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/categories?post=2432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/azure-sql\/wp-json\/wp\/v2\/tags?post=2432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}