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

[Compute] Add Managed Identity Support in Azure Disk Encryption #30457

Merged
merged 19 commits into from
Dec 31, 2024

Conversation

anshuljain26
Copy link
Contributor

@anshuljain26 anshuljain26 commented Dec 3, 2024

Related command

Description
Azure Disk Encryption (ADE) is adding support for using managed identity to authenticate to customer's keyvault.
As part of it, a new field (EncryptionIdentity) has been added to the VM model. By setting this field customer will be notifying ADE to use that managed identity for keyvault operations. The identity should also be explicitly assigned to the VM.

This PR adds a new parameter (EncryptionIdentity) to Set-AzVMDiskEncryptionExtension cmdlet. If the parameter is present then the cmdlet will update the EncryptionIdentity field.

Encryption Identity field is also updated during VM creation if the encryption identity is a part of the identities assigned to the vm
Testing Guide

History Notes

[Compute] az vm create: Add --encryption-identity parameter to use that managed identity for Azure disk encryption
[Compute] az vm encryption enable: Add --encryption-identity parameter to update or set encryption identity for Azure disk encryption

This checklist is used to make sure that common guidelines for a pull request are followed.

Copy link

azure-client-tools-bot-prd bot commented Dec 3, 2024

️✔️AzureCLI-FullTest
️✔️acr
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️acs
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️advisor
️✔️latest
️✔️3.12
️✔️3.9
️✔️ams
️✔️latest
️✔️3.12
️✔️3.9
️✔️apim
️✔️latest
️✔️3.12
️✔️3.9
️✔️appconfig
️✔️latest
️✔️3.12
️✔️3.9
️✔️appservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️aro
️✔️latest
️✔️3.12
️✔️3.9
️✔️backup
️✔️latest
️✔️3.12
️✔️3.9
️✔️batch
️✔️latest
️✔️3.12
️✔️3.9
️✔️batchai
️✔️latest
️✔️3.12
️✔️3.9
️✔️billing
️✔️latest
️✔️3.12
️✔️3.9
️✔️botservice
️✔️latest
️✔️3.12
️✔️3.9
️✔️cdn
️✔️latest
️✔️3.12
️✔️3.9
️✔️cloud
️✔️latest
️✔️3.12
️✔️3.9
️✔️cognitiveservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️compute_recommender
️✔️latest
️✔️3.12
️✔️3.9
️✔️computefleet
️✔️latest
️✔️3.12
️✔️3.9
️✔️config
️✔️latest
️✔️3.12
️✔️3.9
️✔️configure
️✔️latest
️✔️3.12
️✔️3.9
️✔️consumption
️✔️latest
️✔️3.12
️✔️3.9
️✔️container
️✔️latest
️✔️3.12
️✔️3.9
️✔️containerapp
️✔️latest
️✔️3.12
️✔️3.9
️✔️core
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️cosmosdb
️✔️latest
️✔️3.12
️✔️3.9
️✔️databoxedge
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️dls
️✔️latest
️✔️3.12
️✔️3.9
️✔️dms
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventgrid
️✔️latest
️✔️3.12
️✔️3.9
️✔️eventhubs
️✔️latest
️✔️3.12
️✔️3.9
️✔️feedback
️✔️latest
️✔️3.12
️✔️3.9
️✔️find
️✔️latest
️✔️3.12
️✔️3.9
️✔️hdinsight
️✔️latest
️✔️3.12
️✔️3.9
️✔️identity
️✔️latest
️✔️3.12
️✔️3.9
️✔️iot
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️keyvault
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️lab
️✔️latest
️✔️3.12
️✔️3.9
️✔️managedservices
️✔️latest
️✔️3.12
️✔️3.9
️✔️maps
️✔️latest
️✔️3.12
️✔️3.9
️✔️marketplaceordering
️✔️latest
️✔️3.12
️✔️3.9
️✔️monitor
️✔️latest
️✔️3.12
️✔️3.9
️✔️mysql
️✔️latest
️✔️3.12
️✔️3.9
️✔️netappfiles
️✔️latest
️✔️3.12
️✔️3.9
️✔️network
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️policyinsights
️✔️latest
️✔️3.12
️✔️3.9
️✔️privatedns
️✔️latest
️✔️3.12
️✔️3.9
️✔️profile
️✔️latest
️✔️3.12
️✔️3.9
️✔️rdbms
️✔️latest
️✔️3.12
️✔️3.9
️✔️redis
️✔️latest
️✔️3.12
️✔️3.9
️✔️relay
️✔️latest
️✔️3.12
️✔️3.9
️✔️resource
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️role
️✔️latest
️✔️3.12
️✔️3.9
️✔️search
️✔️latest
️✔️3.12
️✔️3.9
️✔️security
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicebus
️✔️latest
️✔️3.12
️✔️3.9
️✔️serviceconnector
️✔️latest
️✔️3.12
️✔️3.9
️✔️servicefabric
️✔️latest
️✔️3.12
️✔️3.9
️✔️signalr
️✔️latest
️✔️3.12
️✔️3.9
️✔️sql
️✔️latest
️✔️3.12
️✔️3.9
️✔️sqlvm
️✔️latest
️✔️3.12
️✔️3.9
️✔️storage
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️synapse
️✔️latest
️✔️3.12
️✔️3.9
️✔️telemetry
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9
️✔️util
️✔️latest
️✔️3.12
️✔️3.9
️✔️vm
️✔️2018-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2019-03-01-hybrid
️✔️3.12
️✔️3.9
️✔️2020-09-01-hybrid
️✔️3.12
️✔️3.9
️✔️latest
️✔️3.12
️✔️3.9

Copy link

azure-client-tools-bot-prd bot commented Dec 3, 2024

⚠️AzureCLI-BreakingChangeTest
⚠️vm
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd vm create cmd vm create added parameter encryption_identity
⚠️ 1006 - ParaAdd vm encryption enable cmd vm encryption enable added parameter encryption_identity

Copy link

github-actions bot commented Dec 3, 2024

⚠️Your changes in this PR will be released on Jan 14, 2025 due to CCOA (extend to Jan 6, 2025)

@yonzhan
Copy link
Collaborator

yonzhan commented Dec 3, 2024

Thank you for your contribution! We will review the pull request and get back to you soon.

@anshuljain26 anshuljain26 changed the title ADE with MSI Cli support ADE MSI Cli Support Dec 4, 2024
@anshuljain26 anshuljain26 marked this pull request as ready for review December 12, 2024 06:27
@anshuljain26 anshuljain26 changed the title ADE MSI Cli Support ADE With MSI Cli Support Dec 12, 2024
@wangzelin007
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

Comment on lines 91 to 94
if not cmd.supported_api_version(min_api='2023-07-01', resource_type=ResourceType.MGMT_COMPUTE):
raise CLIError("Usage error: Encryption identity is not available under current profile."
"You can set the cloud's profile to latest with:"
"az cloud set --profile latest --name <cloud name>")
Copy link
Member

@wangzelin007 wangzelin007 Dec 13, 2024

Choose a reason for hiding this comment

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

Suggested change
if not cmd.supported_api_version(min_api='2023-07-01', resource_type=ResourceType.MGMT_COMPUTE):
raise CLIError("Usage error: Encryption identity is not available under current profile."
"You can set the cloud's profile to latest with:"
"az cloud set --profile latest --name <cloud name>")
if not cmd.supported_api_version(min_api='2023-07-01', resource_type=ResourceType.MGMT_COMPUTE):
raise CLIError("Usage error: Encryption identity requires API version 2023-07-01 or higher."
"You can set the cloud's profile to use the required API version with:"
"az cloud set --profile latest --name <cloud name>")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed suggestion

Comment on lines 1149 to 1152
if not cmd.supported_api_version(min_api='2023-07-01', resource_type=ResourceType.MGMT_COMPUTE):
raise CLIInternalError("Usage error: Encryption identity is not available under current profile."
"You can set the cloud's profile to latest with:"
"az cloud set --profile latest --name <cloud name>")
Copy link
Member

@wangzelin007 wangzelin007 Dec 13, 2024

Choose a reason for hiding this comment

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

Suggested change
if not cmd.supported_api_version(min_api='2023-07-01', resource_type=ResourceType.MGMT_COMPUTE):
raise CLIInternalError("Usage error: Encryption identity is not available under current profile."
"You can set the cloud's profile to latest with:"
"az cloud set --profile latest --name <cloud name>")
if not cmd.supported_api_version(min_api='2023-07-01', resource_type=ResourceType.MGMT_COMPUTE):
raise CLIInternalError("Usage error: Encryption identity requires API version 2023-07-01 or higher."
"You can set the cloud's profile to use the required API version with:"
"az cloud set --profile latest --name <cloud name>")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed suggestion

@anshuljain26 anshuljain26 changed the title ADE With MSI Cli Support [VM] ADE With MSI Cli Support Dec 13, 2024
@anshuljain26
Copy link
Contributor Author

/azp run

Copy link

Commenter does not have sufficient privileges for PR 30457 in repo Azure/azure-cli

@anshuljain26 anshuljain26 changed the title [VM] ADE With MSI Cli Support [VM] Add MSI Support in Azure Disk Encryption Dec 13, 2024
@anshuljain26 anshuljain26 changed the title [VM] Add MSI Support in Azure Disk Encryption [VM] Add Managed Identity Support in Azure Disk Encryption Dec 13, 2024
Comment on lines 1159 to 1166
if 'encryptionIdentity' not in vm_resource['properties']['securityProfile']:
vm_resource['properties']['securityProfile']['encryptionIdentity'] = {}
if 'userAssignedIdentityResourceId' not \
in vm_resource['properties']['securityProfile']['encryptionIdentity'] or \
vm_resource['properties']['securityProfile']['encryptionIdentity']['userAssignedIdentityResourceId'] \
!= encryption_identity:
vm_resource['properties']['securityProfile']['encryptionIdentity']['userAssignedIdentityResourceId'] \
= encryption_identity
Copy link
Contributor

Choose a reason for hiding this comment

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

This judgment condition is too long. Could we assign vm_resource['properties']['securityProfile']['encryptionIdentity'] to a variable to simplify its condition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed suggestion

Comment on lines +1168 to +1169
raise CLIError("Encryption Identity should be an ARM Resource ID of one of the "
"user assigned identities associated to the resource")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
raise CLIError("Encryption Identity should be an ARM Resource ID of one of the "
"user assigned identities associated to the resource")
raise ArgumentUsageError("Encryption Identity should be an ARM Resource ID of one of the "
"user assigned identities associated to the resource")

Copy link
Contributor Author

@anshuljain26 anshuljain26 Dec 23, 2024

Choose a reason for hiding this comment

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

During VM creation if there is any exception, it will throw cliError exception by default, that's why used that cliError exception here

Comment on lines 68 to 69
raise CLIError("Encryption Identity should be an ARM Resource ID of one of the "
"user assigned identities associated to the resource")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
raise CLIError("Encryption Identity should be an ARM Resource ID of one of the "
"user assigned identities associated to the resource")
raise ArgumentUsageError("Encryption Identity should be an ARM Resource ID of one of the "
"user assigned identities associated to the resource")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed suggestion

@zhoxing-ms
Copy link
Contributor

Please refer to this guideline https://github.com/Azure/azure-cli/tree/dev/doc/authoring_command_modules#submitting-pull-requests to add relevant history note, which should include specific new parameter explanations

@wangzelin007
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@evelyn-ys
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@anshuljain26
Copy link
Contributor Author

anshuljain26 commented Dec 23, 2024

@wangzelin007 All the check are working fine and addressed all the comments, could you please help to review the PR?
Thanks

@wangzelin007
Copy link
Member

LGTM.

@anshuljain26
Copy link
Contributor Author

@zhoxing-ms Could you please help to review and approve the PR?
Thanks

@yanzhudd
Copy link
Contributor

yanzhudd commented Dec 30, 2024

Please refer to this guideline https://github.com/Azure/azure-cli/tree/dev/doc/authoring_command_modules#submitting-pull-requests to add relevant history note, which should include specific new parameter explanations

please address this comment, as to specify the impacted commands/parameters in the History Notes section, e.g.,
[Compute] az vm create: Add --xxx parameter to support managed identity in Azure disk encryption

@yanzhudd
Copy link
Contributor

There is a guideline about adding support for managed identity in Azure CLI: https://github.com/Azure/azure-cli/blob/dev/doc/managed_identity_command_guideline.md
Please follow this guildline to develop the managed identity commands.

@zhoxing-ms
Copy link
Contributor

Please address these comments from Yan, I don't have any other comments anymore~

@anshuljain26
Copy link
Contributor Author

anshuljain26 commented Dec 30, 2024

There is a guideline about adding support for managed identity in Azure CLI: https://github.com/Azure/azure-cli/blob/dev/doc/managed_identity_command_guideline.md Please follow this guildline to develop the managed identity commands.

We have added a new Parameter encryption identity to authenticate to customer's keyvault.
As part of it, a new field (EncryptionIdentity) has been added to the VM model. By setting this field customer will be notifying ADE to use that managed identity for keyvault operations. And we want to set this field during vm creation or update it during the encryption

@anshuljain26
Copy link
Contributor Author

Please refer to this guideline https://github.com/Azure/azure-cli/tree/dev/doc/authoring_command_modules#submitting-pull-requests to add relevant history note, which should include specific new parameter explanations

please address this comment, as to specify the impacted commands/parameters in the History Notes section, e.g., [Compute] az vm create: Add --xxx parameter to support managed identity in Azure disk encryption

Done

@yanzhudd
Copy link
Contributor

please follow the specifications in the guideline to submit future PRs and use `` character to quote the command/parameter in the History Notes/title section:
image

@yanzhudd
Copy link
Contributor

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@anshuljain26
Copy link
Contributor Author

Could someone please run /azp run

@yonzhan
Copy link
Collaborator

yonzhan commented Dec 30, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@anshuljain26
Copy link
Contributor Author

@yanzhudd All checks are passing, please have a look

@yanzhudd yanzhudd merged commit fb83fc8 into Azure:dev Dec 31, 2024
53 checks passed
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.

7 participants