Scalr\Service\Azure::assignContributorRoleToApp PHP Method

assignContributorRoleToApp() public method

Assign Contributor Role Id to specified app.
public assignContributorRoleToApp ( string $subscriptionId, string $roleAssignmentId, string $appObjectId, string $contributorRoleId ) : Scalr\Service\Azure\DataType\RoleAssignmentData
$subscriptionId string subscription::subscriptionId value of one of user's subscriptions
$roleAssignmentId string New role assignment id
$appObjectId string Application Object Id
$contributorRoleId string Contributor Role Id
return Scalr\Service\Azure\DataType\RoleAssignmentData Server response body (JSON)
    public function assignContributorRoleToApp($subscriptionId, $roleAssignmentId, $appObjectId, $contributorRoleId)
    {
        $result = null;
        $path = '/subscriptions/' . $subscriptionId . '/providers/Microsoft.Authorization/roleAssignments/' . $roleAssignmentId;
        $headers = ['Authorization' => 'Bearer ' . $this->getAccessToken()->token];
        $requestData = ['properties' => ['roleDefinitionId' => "/subscriptions/" . $subscriptionId . "/providers/Microsoft.Authorization/roleDefinitions/" . $contributorRoleId, 'principalId' => $appObjectId, 'scope' => '/subscriptions/' . $subscriptionId]];
        $request = $this->getClient()->prepareRequest($path, 'PUT', self::RESOURCE_API_VERSION, Azure::URL_MANAGEMENT_WINDOWS, [], $requestData, $headers);
        $response = $this->getClient()->call($request);
        if (!$response->hasError()) {
            $result = RoleAssignmentData::initArray($response->getResult());
        }
        return $result;
    }