Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure: Changes to managed identity steps so they are compatible with functions settings conversion #1889

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

motm32
Copy link
Contributor

@motm32 motm32 commented Feb 24, 2025

Needed to make a couple changes to make the current managed identity steps compatible with converting settings.

Things I have changed:

  • Adding a ResourceGroupListStep to the UserAssignedIdentityListStep. Users who are converting will not have specified a resource group prior to choosing to create a managed identity
  • Allow RoleAssignmentExecuteStep to assign multiple roles in the step. It is common not only for converting to assign more than one role
  • Added more common role types and also made changes to how we get the id for the roles as that uses a users subscriptionId

TODO:

  • put up the functions PR to show how these changes are used.

@motm32 motm32 requested a review from a team as a code owner February 24, 2025 20:58
@@ -506,4 +511,69 @@ export declare const CommonRoleDefinitions: {
readonly description: "Allows for read, write and delete access to Azure Storage blob containers and data";
readonly roleType: "BuiltInRole";
};
readonly storageBlobDataOwner: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where'd you find all this info from? I would put a link in a comment so we know where to get it in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add a link

azure/index.d.ts Outdated

public execute(wizardContext: T, progress: Progress<{ message?: string; increment?: number }>): Promise<void>;
public shouldExecute(wizardContext: T): boolean;
}

export interface Roles {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would Role be more accurate?

alexweininger
alexweininger previously approved these changes Feb 26, 2025
@MicroFish91
Copy link
Contributor

Nit but do we want to localize the role descriptions?

} as RoleDefinition
} as const;

export function createRoleId(subscriptionId: string, roleId: string): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think an easier to understand way to do this is to change the roleId: string param into role: CommonRoleDefinitions and then in the function itself, access the role id by doing role.name

const resourceType = scopeSplitArr[scopeSplitArr.length - 2] ?? '';
const roles = this.roles();
if (roles) {
for (const role of roles) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we would want to make the whole step fail if one role fails. Maybe do a try/catch so it can continue?

Comment on lines +394 to +398
export interface Role {
scopeId: string | undefined;
roleDefinitionId: string;
roleDefinitionName: string;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add doc strings to this interface?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants