Skip to content

Databricks App with dynamic values from the target variables #3679

@ne250040

Description

@ne250040

I have a databricks app that works well with hardcoded values on the app.yml file. However when i specify a variable on this file, it does not get resolved to the value from target variable. I dont see an example for doing this. I was able to make use of sql-warehouse to get the warehouse-id, however the custom variables dont work similar way. does the CLI support the custom variables yet? Is there another way to pass variables dynamically?

The way i have structured the files:

databricks.yml:

bundle:
  name: etl_deploy

include:
  - common/*.yml

variables:
  db_connection:
    description: connections to databases
    default: "unknown"

targets:
  dev:
    mode: development
    default: true
    workspace:
      host: https://11111111.4.gcp.databricks.com/
    variables:
      short_env_name: dev
      permission_level: CAN_MANAGE
      schedule_state: PAUSED
      db_connection: salesforce_dev
  qal:
    mode: production
    default: true
    workspace:
      host: https://1234567.1.gcp.databricks.com/
    variables:
      short_env_name: qal
      permission_level: CAN_RUN
      schedule_state: UNPAUSED
      db_connection: salesforce_uat

Streamlit app's app.yml file:

command:
  - "streamlit"
  - "run"
  - "app.py"

env:
  - name: SQL_WAREHOUSE_ID
    valueFrom: sql-warehouse
  - name: DB_CONNECTION
    value: ${var.db_connection}

resources data.app.yml file

resources:
  apps:
    query-data:
      name: query-data
      description: 'To get sales data from the delta table'

      source_code_path: ../app

      resources:
        - name: "sql-warehouse"
          sql_warehouse:
            id: ${var.sql_warehouse_id}
            permission: "CAN_MANAGE"
      permissions:
        - level: CAN_MANAGE
          group_name: ${var.access_group}
​```

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions