Question:
I am trying to assign role on web app using VSTS but below error displayed.
Powershell :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$webappname = "devt002" $resourcegroup = "devt002RG" #Get webapp object id $webapp = Get-AzureRmWebApp -ResourceGroupName "$resourcegroup" -Name "$webappname" $objectid = [System.Guid]::Parse($webapp.Identity.PrincipalId) write-host "Object ID datatype :" $objectid.GetType().FullName write-host "Object ID :" $objectid #Get Assign role if already exist $roles = Get-AzureRmRoleAssignment -ObjectId $objectid write-host "Already Assigned Roles :" $roles.RoleDefinitionName |
Error :
1 2 3 4 |
2019-04-05T11:20:23.7408185Z ##[debug]Caught exception from task script. 2019-04-05T11:20:23.7408790Z ##[debug]Error record: 2019-04-05T11:20:23.7408993Z ##[debug]Get-AzureRmRoleAssignment : Exception of type 'Microsoft.Rest.Azure.CloudException' was thrown. |
Note : It is working fine in local powershell client. Issue only with VSTS.
Answer:
Check have you provided correct Object ID. If you are providing Object ID via Variables, Value needs to be changed.