I am trying to assign role on web app using VSTS but below error displayed.
Powershell :
$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 :
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.
Check have you provided correct Object ID. If you are providing Object ID via Variables, Value needs to be changed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With