Skip to content

Commit

Permalink
Add output log to role assignment creation
Browse files Browse the repository at this point in the history
  • Loading branch information
nturinski committed Jul 19, 2024
1 parent 7df6d33 commit 8e4e2e2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions azure/src/wizard/RoleAssignmentExecuteStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { randomUUID } from 'crypto';
import { l10n, Progress } from 'vscode';
import * as types from '../../index';
import { createAuthorizationManagementClient } from '../clients';
import { ext } from '../extensionVariables';

export enum RoleDefinitionId {
StorageBlobDataContributor = '/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe'
Expand All @@ -31,9 +32,12 @@ export class RoleAssignmentExecuteStep<T extends types.IResourceGroupWizardConte
}

const guid = randomUUID();
const roleDefinitionDisplayName = Object.keys(RoleDefinitionId)[Object.values(RoleDefinitionId).indexOf(this._roleDefinitionId)];
const roleDefinitionId = this._roleDefinitionId as unknown as string;
const principalId = nonNullValueAndProp(wizardContext.managedIdentity, 'principalId');
await amClient.roleAssignments.create(scope, guid, { roleDefinitionId, principalId });
const roleAssignmentCreated = l10n.t('Role assignment "{1}" created with resource "{0}".', scope, roleDefinitionDisplayName);
ext.outputChannel.appendLog(roleAssignmentCreated);
}

public shouldExecute(wizardContext: T): boolean {
Expand Down

0 comments on commit 8e4e2e2

Please sign in to comment.