0

I am using Azure Devops Pipeline.

I create a ServiceConnection in Azure Devops and added an Service Principal in it.

Agent i am using is 'ubuntu-latest'

I created a powershell task in pipeline

- task: AzureCLI@2        
  displayName: 'Assign Role'
  name: task_inline
  inputs:
    scriptType: 'pscore'
    azureSubscription: 'AzureConnRM'
    scriptLocation: scriptPath
    addSpnToEnvironment: true
    scriptPath: './abc.ps1'

In Powershell to update an existing RBAC Role i am running below command:

az role assignment update --role-assignment $myjson  --debug --verbose

and json which i am passing is

$myjson = '{
  "conditionVersion": "",
  "roleDefinitionName": "Contributor",
  "principalType": "User",
  "condition": "",
  "id": "/subscriptions/097ca710-067e-4a70-8ce6-494268568148/resourceGroups/Trial-RG/providers/Microsoft.Authorization/roleAssignments/45d7dc3c-4a95-8a1c-bd87-f8a460c6d255",
  "resourceGroup": "Trial-RG",
  "roleDefinitionId": "/subscriptions/097ca710-067e-4a70-8ce6-494268568148/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c",
  "type": "Microsoft.Authorization/roleAssignments",
  "scope": "/subscriptions/097ca710-067e-4a70-8ce6-494268568148/resourceGroups/Trial-RG",
  "principalId": "8cd5df22-42f4-405e-b3ab-d562eaf1da92",
  "canDelegate": "",
  "description": "Updated",
  "name": "45d7dc3c-4a95-8a1c-bd87-f8a460c6d255"
  }'

But get the error:

Error detail: Expecting property name enclosed in double quotes: line 2 column 3 (char 4)

ABC DEF
  • 189
  • 2
  • 14
  • 1
    think you face the same issue? https://stackoverflow.com/questions/60819537/expecting-property-name-enclosed-in-double-quotes-when-passing-json-string-to-az – Toni Sep 27 '22 at 16:18

1 Answers1

1

Thanks @Toni --debug helped me see the detailed log. 3 fields conditionVersion, canDelegate, condition were not getting set correctly. I removed these properties from my json and it worked.

ABC DEF
  • 189
  • 2
  • 14