<?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 Use a Service Principal Token instead of Personal Access Token for Databricks Asset Bundle in Administration &amp; Architecture</title>
    <link>https://community.databricks.com/t5/administration-architecture/use-a-service-principal-token-instead-of-personal-access-token/m-p/91629#M1886</link>
    <description>&lt;P&gt;How can I connect using a Service Principal Token, I did this, but it is not a PAT:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;databricks configure
Databricks host: https:// ...
Personal access token: ****&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I also tried this, but didn't work either:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[profile]
host = &amp;lt;workspace-url&amp;gt;
client_id = &amp;lt;service-principal-client-id&amp;gt;
client_secret = &amp;lt;service-principal-secret&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I tried this way, but nothing (just in case):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;databricks configure --aad-token&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;How can I configure my Databricks workspace so I can deploy DAB in that workspace, but using the service-principal token (for no relying in PAT's)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards, and thank you&lt;/P&gt;&lt;P&gt;#DAB #DatabricksAssetsBundle #ServicePrincipal&lt;/P&gt;</description>
    <pubDate>Tue, 24 Sep 2024 21:11:37 GMT</pubDate>
    <dc:creator>PabloCSD</dc:creator>
    <dc:date>2024-09-24T21:11:37Z</dc:date>
    <item>
      <title>Use a Service Principal Token instead of Personal Access Token for Databricks Asset Bundle</title>
      <link>https://community.databricks.com/t5/administration-architecture/use-a-service-principal-token-instead-of-personal-access-token/m-p/91629#M1886</link>
      <description>&lt;P&gt;How can I connect using a Service Principal Token, I did this, but it is not a PAT:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;databricks configure
Databricks host: https:// ...
Personal access token: ****&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I also tried this, but didn't work either:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[profile]
host = &amp;lt;workspace-url&amp;gt;
client_id = &amp;lt;service-principal-client-id&amp;gt;
client_secret = &amp;lt;service-principal-secret&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I tried this way, but nothing (just in case):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;databricks configure --aad-token&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;How can I configure my Databricks workspace so I can deploy DAB in that workspace, but using the service-principal token (for no relying in PAT's)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards, and thank you&lt;/P&gt;&lt;P&gt;#DAB #DatabricksAssetsBundle #ServicePrincipal&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2024 21:11:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/use-a-service-principal-token-instead-of-personal-access-token/m-p/91629#M1886</guid>
      <dc:creator>PabloCSD</dc:creator>
      <dc:date>2024-09-24T21:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: Use a Service Principal Token instead of Personal Access Token for Databricks Asset Bundle</title>
      <link>https://community.databricks.com/t5/administration-architecture/use-a-service-principal-token-instead-of-personal-access-token/m-p/91645#M1890</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/106298"&gt;@PabloCSD&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Long story short you can watch this &lt;A href="https://www.youtube.com/watch?v=HDLke-D5RBQ&amp;amp;t=632s" target="_self"&gt;video&lt;/A&gt; where I go step by step on how to set up service principal in azure, grant permissions to workspace and generate a token to itself by doing a machine to machine authentication in the Databricks CLI.&lt;/P&gt;&lt;P&gt;The steps that you need to take to deploy your bundle using service principle.&lt;/P&gt;&lt;P&gt;1.Add service principal to your Databricks Account&lt;/P&gt;&lt;P&gt;2.Give that service principal administration rights to the workspace you want to deploy the DAB&lt;/P&gt;&lt;P&gt;3. Generate a PAT (personal access token) to the service principal. Which you can do in 2 ways.&lt;/P&gt;&lt;P&gt;3.a Either via a Machine to Machine authentication where the service principal generate a PAT to itself. I demonstrate this in the video&lt;/P&gt;&lt;P&gt;3,b or you can generate a token to the sp by using the "on behalf" option providing the principal generating the token has at least the workspace administration writes. On this post there is a &lt;A href="https://youtu.be/HDLke-D5RBQ?si=QxknIewaxW9iWAKz&amp;amp;t=39" target="_self"&gt;solution&lt;/A&gt; for this option.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To deploy your bundle using the cli you will use the command&lt;/P&gt;&lt;P&gt;databricks bundle deploy -t &amp;lt;target-name&amp;gt; -p &amp;lt;sp-profile&amp;gt;&lt;/P&gt;&lt;P&gt;The service principle profile needs to have your service principal configured on your ~/.databrickscfg file either with a machine to machine (oauth token) or pat (personal access token)&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;&lt;P&gt;Let me know if you can solve your issue. If any other questions I am here to help&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Pedro&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 04:29:41 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/use-a-service-principal-token-instead-of-personal-access-token/m-p/91645#M1890</guid>
      <dc:creator>dataeng42io</dc:creator>
      <dc:date>2024-09-25T04:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Use a Service Principal Token instead of Personal Access Token for Databricks Asset Bundle</title>
      <link>https://community.databricks.com/t5/administration-architecture/use-a-service-principal-token-instead-of-personal-access-token/m-p/91653#M1892</link>
      <description>&lt;P&gt;Just adding the documentation about authentication -&amp;gt;&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/azure/databricks/dev-tools/cli/authentication#m2m-auth" target="_blank"&gt;https://learn.microsoft.com/en-us/azure/databricks/dev-tools/cli/authentication#m2m-auth&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2024 05:45:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/use-a-service-principal-token-instead-of-personal-access-token/m-p/91653#M1892</guid>
      <dc:creator>dataeng42io</dc:creator>
      <dc:date>2024-09-25T05:45:59Z</dc:date>
    </item>
    <item>
      <title>Re: Use a Service Principal Token instead of Personal Access Token for Databricks Asset Bundle</title>
      <link>https://community.databricks.com/t5/administration-architecture/use-a-service-principal-token-instead-of-personal-access-token/m-p/91890#M1915</link>
      <description>&lt;P&gt;Thanks Pedro, we did it, for anyone in the future (I added fake host and service principal id's):&lt;/P&gt;&lt;P&gt;1. Modify your &lt;SPAN&gt;&lt;SPAN class=""&gt;databricks.yml so it have the service principal id and the databricks host:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;bundle:
  name: my_workflow

# Declare to Databricks Assets Bundles that this is a Python project
# This is the interaction with the "pyproject.toml" file
artifacts:
  default:
    type: whl
    build: poetry build
    path: .

resources:
  jobs:
    my_workflow:
      name: my_workflow
      job_clusters:
        - job_cluster_key: ${bundle.target}-${bundle.name}-job-cluster
          new_cluster:
                num_workers: 2
                spark_version: "15.3.x-cpu-ml-scala2.12"  
                node_type_id: Standard_DS3_v2      
      tasks:
        - task_key: my_workflow_pipeline_task
          job_cluster_key: ${bundle.target}-${bundle.name}-job-cluster
          python_wheel_task:
             package_name: my_workflow
             entry_point: my_workflow_pipeline_task
          libraries:
            - whl: ./dist/*.whl
      permissions:
        # If you are using a group, you need to create it in the Databricks workspace
        - group_name: "my_group_name"
          level: "CAN_MANAGE"

targets:
  dev:
    mode: development
    default: true
    workspace: 
      # Put here the associated workspace url
      host: https://adb-0000000000000000.7.azuredatabricks.net
    run_as:
      # Put here the associated service_principal_name
      service_principal_name: 76w4hdge-39a2-0303-45c7-udnr93kvp03f
    resources:
      jobs:
        my_workflow:
          job_clusters:
            - job_cluster_key: ${bundle.target}-${bundle.name}-job-cluster
              new_cluster:
                num_workers: 2
                spark_version: "15.3.x-cpu-ml-scala2.12"  
                node_type_id: Standard_DS3_v2
          permissions:
          # If you are using a group, you need to create it in the Databricks workspace
          - group_name: "my_group_name"
            level: "CAN_MANAGE"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Create a &lt;SPAN&gt;&lt;SPAN class=""&gt;.databrickscfg&lt;/SPAN&gt;&lt;/SPAN&gt; file in the same route where your&amp;nbsp;&lt;SPAN&gt;&lt;SPAN class=""&gt;databricks-cli&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt; is installed, so it has the following information:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[my_workflow]
host=https://adb-0000000000000000.7.azuredatabricks.net/
client_id = 76w4hdge-39a2-0303-45c7-udnr93kvp03f
client_secret = tomatoes***************spinach&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3. In the terminal just run:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;databricks bundle deploy --profile my_workflow&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If all was done correctly this should be the output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(.venv) oishiiramen@3301 my_directory % databricks bundle deploy --profile my_workflow
Building default...
Uploading my_workflow-0.1.1-py3-none-any.whl...
Uploading bundle files to /Users/76w4hdge-39a2-0303-45c7-udnr93kvp03f/.bundle/my_workflow/dev/files...
Deploying resources...
Updating deployment state...
Deployment complete!&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the .&lt;SPAN&gt;&lt;SPAN class=""&gt;databrickscfg was not created this could appear:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(.venv) oishiiramen@3301 my_directory % databricks bundle deploy --profile my_workflow
Error: cannot resolve bundle auth configuration: cannot parse config file: open /Users/oishiiramen/.databrickscfg: no such file or directory&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 14:03:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/administration-architecture/use-a-service-principal-token-instead-of-personal-access-token/m-p/91890#M1915</guid>
      <dc:creator>PabloCSD</dc:creator>
      <dc:date>2024-09-26T14:03:05Z</dc:date>
    </item>
  </channel>
</rss>

