rAJ
rAJ

Reputation: 1433

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.

Upvotes: 5

Views: 3552

Answers (1)

user13442381
user13442381

Reputation: 11

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

Upvotes: 1

Related Questions