Skip to content

[Bug]: env() transformation does not work after upgrading the project from 0.7.6 to 0.9.7 #1956

@anielii

Description

@anielii

What happened?

Hi,

After upgrading my project from 0.7.6 to 0.9.7, the @env() transformation stopped working. The environment variables are not replaced at all. I have the same problem both locally (CLI update) and in Azure ContainerApps (image update).

In the past, for 0.7.6, when I was developing locally, I set the environment variables in the terminal in the following way and everything worked fine without any problems. I get the same problem when I try to use the .env file.

Is there a new undocumented option to enable environment variable replacement?

$env:DATABASE_NAME = 'abc'
$env:DATABASE_CONNECTION_STRING = 'abc'
$env:GRAPHQL_SCHEMA_PATH = 'dab-config.schema.gql'
$env:JWT_AUDIENCE = 'abc'
$env:JWT_ISSUER = 'abc'

dab start

dab-config.json:

{
  "$schema": "https://github.com/Azure/data-api-builder/releases/download/v0.7.6/dab.draft.schema.json",
  "data-source": {
    "database-type": "cosmosdb_nosql",
    "options": {
      "database": "@env('DATABASE_NAME')",
      "schema": "@env('GRAPHQL_SCHEMA_PATH')"
    },
    "connection-string": "@env('DATABASE_CONNECTION_STRING')"
  },
  "runtime": {
    "rest": {
      "enabled": true,
      "path": "/api"
    },
    "graphql": {
      "allow-introspection": true,
      "enabled": true,
      "path": "/graphql"
    },
    "host": {
      "mode": "development",
      "cors": {
        "origins": [],
        "allow-credentials": false
      },
      "authentication": {
        "provider": "AzureAD",
        "jwt": {
          "audience": "@env('JWT_AUDIENCE')",
          "issuer": "@env('JWT_ISSUER')"
        }
      }
    }
  },
  "entities": {
    "NoteCard": {
      "source": "NoteCards",
      "permissions": [
        {
          "role": "authenticated",
          "actions": [
            "*"
          ]
        }
      ]
    }
  }
}

Version

0.9.7

What database are you using?

CosmosDB NoSQL

What hosting model are you using?

Local (including CLI), Container Apps

Which API approach are you accessing DAB through?

REST, GraphQL

Relevant log output

PS D:\r\DigestFusion\scripts\data-api-builder\cosmos> dab start
Information: Microsoft.DataApiBuilder 0.9.7+e560142426d1c080b9fd7b7fabff51a276f6bf61
Information: Config not provided. Trying to get default config based on DAB_ENVIRONMENT...
Information: Environment variable DAB_ENVIRONMENT is development
Loading config file from dab-config.json.
Information: Loaded config file: dab-config.json
Information: Setting default minimum LogLevel: Debug for Development mode.
Starting the runtime engine...
Loading config file from dab-config.json.
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[63]
      User profile is available. Using 'C:\Users\nieli\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
fail: Azure.DataApiBuilder.Service.Startup[0]
      Unable to complete runtime initialization. Refer to exception for error details.
      System.IO.FileNotFoundException: The GraphQL schema file at '@env('GRAPHQL_SCHEMA_PATH')' could not be found. Ensure that it is a path relative to the runtime.
         at Azure.DataApiBuilder.Core.Configurations.RuntimeConfigValidator.ValidateDatabaseType(RuntimeConfig runtimeConfig, IFileSystem fileSystem, ILogger logger)
         at Azure.DataApiBuilder.Core.Configurations.RuntimeConfigValidator.ValidateConfig()
         at Azure.DataApiBuilder.Service.Startup.PerformOnConfigChangeAsync(IApplicationBuilder app)
fail: Azure.DataApiBuilder.Service.Startup[0]
      Could not initialize the engine with the runtime config file: dab-config.json
info: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...
Unable to launch the Data API builder engine.
Error: Failed to start the engine.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Labels

bugSomething isn't workingcriCustomer Reported issuetriageissues to be triaged

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions