<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using variables with Databricks Asset Bundles not working in Machine Learning</title>
    <link>https://community.databricks.com/t5/machine-learning/using-variables-with-databricks-asset-bundles-not-working/m-p/88660#M3641</link>
    <description>&lt;P&gt;Great, glad that it worked!&lt;/P&gt;</description>
    <pubDate>Thu, 05 Sep 2024 07:05:16 GMT</pubDate>
    <dc:creator>szymon_dybczak</dc:creator>
    <dc:date>2024-09-05T07:05:16Z</dc:date>
    <item>
      <title>Using variables with Databricks Asset Bundles not working</title>
      <link>https://community.databricks.com/t5/machine-learning/using-variables-with-databricks-asset-bundles-not-working/m-p/88458#M3637</link>
      <description>&lt;P&gt;Hi Everyone&lt;/P&gt;&lt;P&gt;I am using the default Databricks Asset Bundle. All is good except i can get stage dependt variables to work.&lt;/P&gt;&lt;P&gt;i have a bundle config file that looks like the below, where i have defined variables for each stage.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;bundle:
  name: xxxxx

include:
  - resources/*.yml

targets:
  # The 'dev' target, for development purposes. This target is the default.
  dev:
    variables:
      env: 
        description: target environment for fetching secrets from the relevant keyvault scope
        default: test
    # We use 'mode: development' to indicate this is a personal development copy:
    # - Deployed resources get prefixed with '[dev my_user_name]'
    # - Any job schedules and triggers are paused by default
    # - The 'development' mode is used for Delta Live Tables pipelines
    mode: development
    default: true
    workspace:
      host: adb-xxxxx.azuredatabricks.net 

# The 'prod' target, used for production deployment.
  prod:
    variables: 
      env: 
        description: target environment for fetching secrets from the relevant keyvault scope
        default: prod
    # We use 'mode: production' to indicate this is a production deployment.
    # Doing so enables strict verification of the settings below.
    mode: production
    workspace:
      host: adb-xxxxx.azuredatabricks.net
      # We always use /Users/xxx@xxx.dk for all resources to make sure we only have a single copy.
      # If this path results in an error, please make sure you have a recent version of the CLI installed.
      root_path: /Users/xxx@xxx.dk/.bundle/${bundle.name}/${bundle.target}
    run_as:
      # This runs as xxx@xxx.dk in production. We could also use a service principal here,
      # see https://docs.databricks.com/dev-tools/bundles/permissions.html.
      user_name: xxx@xxx.dk&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;however, when i run fx "databricks bundle deploy" i get the error "Error: variable env is not defined but is assigned a value"&lt;/P&gt;&lt;P&gt;i have tried to set the env var with --var="env=test" also&lt;/P&gt;&lt;P&gt;I try to call the env var from the base_parameters slot in following resource file .yml:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# The main job for xxxx.
resources:
  jobs:
    xxxxx:
      name: xxxx

      schedule:
        # Run At 09:00:00am, on every Saturday, every month
        quartz_cron_expression: '0 0 9 ? * SAT *'
        timezone_id: Europe/Amsterdam

      email_notifications:
        on_failure:
          - xxxx

      tasks:
        - task_key: notebook_task
          job_cluster_key: job_cluster
          notebook_task:
            notebook_path: ../src/notebook.ipynb
            base_parameters:
              ENV: ${var.env}
        
      job_clusters:
        - job_cluster_key: job_cluster
          new_cluster:
            spark_version: 13.3.x-scala2.12
            node_type_id: Standard_D3_v2
            autoscale:
                min_workers: 1
                max_workers: 1&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;help would be much appreciated.&lt;/P&gt;&lt;P&gt;kind regards&lt;/P&gt;&lt;P&gt;Niels&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 13:20:10 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/using-variables-with-databricks-asset-bundles-not-working/m-p/88458#M3637</guid>
      <dc:creator>NielsMH</dc:creator>
      <dc:date>2024-09-04T13:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables with Databricks Asset Bundles not working</title>
      <link>https://community.databricks.com/t5/machine-learning/using-variables-with-databricks-asset-bundles-not-working/m-p/88479#M3638</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/91840"&gt;@NielsMH&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I think there is small issue with your template. You missed variables mapping at the top level.&lt;/P&gt;&lt;P&gt;According to the documentation:&amp;nbsp;&lt;/P&gt;&lt;P&gt;"The bundles settings file can contain one top-level variables mapping to specify variable settings to use."&lt;/P&gt;&lt;P&gt;Add env variable to the root level. Then the error that is saying that you didn't define variable should vanished.&amp;nbsp;&lt;/P&gt;&lt;P&gt;And you can override top level variables with target mapping, as in your example &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/azure/databricks/dev-tools/bundles/settings#targets" target="_blank"&gt;https://learn.microsoft.com/en-us/azure/databricks/dev-tools/bundles/settings#targets&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2024 13:51:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/using-variables-with-databricks-asset-bundles-not-working/m-p/88479#M3638</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2024-09-04T13:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables with Databricks Asset Bundles not working</title>
      <link>https://community.databricks.com/t5/machine-learning/using-variables-with-databricks-asset-bundles-not-working/m-p/88654#M3640</link>
      <description>&lt;P&gt;Hi Slash. That was indeed the problem. Thanks! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 06:42:24 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/using-variables-with-databricks-asset-bundles-not-working/m-p/88654#M3640</guid>
      <dc:creator>NielsMH</dc:creator>
      <dc:date>2024-09-05T06:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables with Databricks Asset Bundles not working</title>
      <link>https://community.databricks.com/t5/machine-learning/using-variables-with-databricks-asset-bundles-not-working/m-p/88660#M3641</link>
      <description>&lt;P&gt;Great, glad that it worked!&lt;/P&gt;</description>
      <pubDate>Thu, 05 Sep 2024 07:05:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/using-variables-with-databricks-asset-bundles-not-working/m-p/88660#M3641</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2024-09-05T07:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using variables with Databricks Asset Bundles not working</title>
      <link>https://community.databricks.com/t5/machine-learning/using-variables-with-databricks-asset-bundles-not-working/m-p/107274#M3922</link>
      <description>&lt;P&gt;yes this worked, you need to add the variables at both places i.e. the top level and set default values, and then add them again to the target as a mapping ( non default values).&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;bundle&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;# Required.&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;name&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;string&lt;/SPAN&gt; &lt;SPAN class=""&gt;# Required.&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;databricks_cli_version&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;string&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;cluster_id&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;string&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;git&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;origin_url&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;string&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;branch&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;string&lt;/SPAN&gt;

&lt;SPAN class=""&gt;# These are for any custom variables for use throughout the bundle.&lt;/SPAN&gt;
&lt;SPAN class=""&gt;variables&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;&amp;lt;some-unique-variable-name&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;description&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;string&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;default&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;string or complex&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN class=""&gt;targets&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
  &lt;SPAN class=""&gt;&amp;lt;some-unique-programmatic-identifier-for-this-target&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;artifacts&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;# See the preceding "artifacts" syntax.&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;bundle&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;# See the preceding "bundle" syntax.&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;cluster_id&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;string&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;default&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;true | false&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;mode&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;development&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;presets&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;&amp;lt;preset&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;&amp;lt;value&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;resources&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;# See the preceding "resources" syntax.&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;sync&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;# See the preceding "sync" syntax.&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;variables&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;&amp;lt;preceding-unique-variable-name&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt; &lt;SPAN class=""&gt;&amp;lt;non-default-value&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;workspace&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;# See the preceding "workspace" syntax.&lt;/SPAN&gt;
    &lt;SPAN class=""&gt;run_as&lt;/SPAN&gt;&lt;SPAN class=""&gt;:&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;# See the preceding "run_as" syntax.&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jan 2025 17:39:36 GMT</pubDate>
      <guid>https://community.databricks.com/t5/machine-learning/using-variables-with-databricks-asset-bundles-not-working/m-p/107274#M3922</guid>
      <dc:creator>stupefyyy</dc:creator>
      <dc:date>2025-01-27T17:39:36Z</dc:date>
    </item>
  </channel>
</rss>

