- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2022 12:23 PM
I am trying to write a process that will programmatically update the “run_as_user_name” parameter for all jobs in an Azure Databricks workspace, using powershell to interact with the Jobs API.
I have been trying to do this with a test job without success. I am, however, able to update different job params, such as job name, for the same job using powershell. This leads me to believe that its not possible to update run_as_user_name via the Jobs api, although I can't find this clearly stated anywhere in documentation.
I’ve tried with both the 2.0 and 2.1 versions of the API. The below powershell works successfully for updating the job name:
#set BaseUrl and headers
$BaseUrl = https://adb-***.azuredatabricks.net
$job_URL = "$BaseUrl/api/2.0/jobs/update"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Bearer XXXX")
#create the json for update
$JobId = '12345'
$paramDetail = '"new_settings": { "name": "change_to_this"}}'
$jobIdDetail = '"job_id":{0}' -f $JobId
$bodyContent = '{' + '{0},{1}' -f $jobIdDetail, $paramDetail + '}'
$bodyContent
#run the update
Invoke-RestMethod $job_URL -Method POST -Headers $headers -Body $bodyContent
However, if I change the following line:
- From: $paramDetail = '"new_settings": { "name": "change_to_this"}}'
- To: $paramDetail = '"new_settings": { "run_as_user_name": “my.user@company.com”}}'
I get no errors (in fact, I get no output at all), but nothing updates in the job within Databricks. Any thoughts on where I'm going wrong?
- Labels:
-
Parameter