Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception of type 'Microsoft.Rest.Azure.CloudException' was thrown

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.

like image 845
rAJ Avatar asked Nov 06 '22 18:11

rAJ


1 Answers

Check have you provided correct Object ID. If you are providing Object ID via Variables, Value needs to be changed.

like image 58
user13442381 Avatar answered Nov 15 '22 06:11

user13442381