Skip to content

[Az.RecoveryServices.Backup] Customer Managed Key Encryption for recovery services vault #13593

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

Merged
merged 2 commits into from
Dec 24, 2020

Conversation

hiaga
Copy link
Member

@hiaga hiaga commented Nov 26, 2020

Description

CMK for V1 vaults

Checklist

  • [Yes] I have read the Submitting Changes section of CONTRIBUTING.md
  • [Yes] The title of the PR is clear and informative
  • [Yes] The appropriate ChangeLog.md file(s) has been updated:
    • For any service, the ChangeLog.md file can be found at src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md
    • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header -- no new version header should be added
  • [Yes] The PR does not introduce breaking changes
  • [N/A] If applicable, the changes made in the PR have proper test coverage
  • [Yes] For public API changes to cmdlets:

@hiaga hiaga self-assigned this Nov 26, 2020
@hiaga hiaga force-pushed the hiaga/CMK branch 5 times, most recently from 1f3b2d8 to 60b4dbd Compare December 21, 2020 08:54
@hiaga hiaga changed the title [Do Not Merge] [Az.RecoveryServices] Customer Managed Key Encryption for V1 vaults [Az.RecoveryServices.Backup] Customer Managed Key Encryption for recovery services vault Dec 21, 2020
@hiaga hiaga assigned isra-fel and wyunchi-ms and unassigned hiaga Dec 21, 2020
@hiaga hiaga force-pushed the hiaga/CMK branch 3 times, most recently from 8efd182 to deaca5d Compare December 22, 2020 01:39
@hiaga
Copy link
Member Author

hiaga commented Dec 22, 2020

@isra-fel : can you pls merge the cmdlet review PR - https://github.com/Azure/azure-powershell-cmdlet-review-pr/issues/793

@isra-fel isra-fel changed the base branch from master to release-2020-12-29 December 22, 2020 09:26
@hiaga hiaga force-pushed the hiaga/CMK branch 3 times, most recently from 8c7fe5d to 8833168 Compare December 23, 2020 04:54
@@ -139,7 +140,7 @@ public override void ExecuteCmdlet()
}

// sleep for 30 seconds before checking again
TestMockSupport.Delay(30 * 1000);
Thread.Sleep(30000);
Copy link
Member

Choose a reason for hiding this comment

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

For such long sleep, we suggest check if it's in a playback test and skip sleep if so. This could save you some time when playback tests.

For example
https://github.com/Azure/azure-powershell/blob/master/src/Accounts/Authentication/Factories/CancelRetryHandler.cs#L66

@@ -51,10 +51,11 @@ Get the list of vault in resource group in selected subscription.
### Example 3

```powershell
PS C:\> Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName"
PS C:\> $vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName"
PS C:\> $vault.Identity
Copy link
Member

Choose a reason for hiding this comment

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

Could use a sample output here, for example

Suggested change
PS C:\> $vault.Identity
PS C:\> $vault.Identity
IdentityType: SystemAssigned
ObjectId: xxx

```
Set-AzRecoveryServicesVaultProperty -SoftDeleteFeatureState <String> [-VaultId <String>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### AzureRSVaultCMKParameterSet
```
Set-AzRecoveryServicesVaultProperty -EncryptionKeyID <string> -KeyVaultSubscriptionId <string> [-InfrastructureEncryption] [-VaultId <String>]
Copy link
Member

Choose a reason for hiding this comment

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

We talked about specifying the key by vault name + key name + (optional) key version, which should be a third parameter set. But it's OK if you choose to add that in the next sprint

Copy link
Member Author

Choose a reason for hiding this comment

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

We are interested in first trying it this way, we can add it next CMK update. Also we aren't sure of hardcoding the Key url because it might use different format in service. is there a way we can construct the exact key.Id with these three values?

Copy link
Member

Choose a reason for hiding this comment

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

It's basically $"https://{KeyVaultName}.{KeyVaultDnsSuffix}/keys/{key-name}" with optional "/{key-version}" at the end.

You can get {KeyVaultDnsSuffix} by DefaultContext.Environment.GetEndpoint(AzureEnvironment.Endpoint.AzureKeyVaultDnsSuffix)

Copy link
Member Author

Choose a reason for hiding this comment

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

Great we would want to add this parameter set later.

fixing static analysis

fixing casing

skipping tests for upcoming release

resolving review comments
@hiaga
Copy link
Member Author

hiaga commented Dec 23, 2020

@isra-fel: added the changes. pls review.

@@ -139,7 +140,12 @@ public override void ExecuteCmdlet()
}

// sleep for 30 seconds before checking again
TestMockSupport.Delay(30 * 1000);
string testMode = Environment.GetEnvironmentVariable("AZURE_TEST_MODE");
Copy link
Member Author

Choose a reason for hiding this comment

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

@isra-fel added this check to skip waiting in case Playback mode. seems like tests are still stuck. can you pls let me know the environment variable for /azp and the value it takes.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry I was wrong. We didn't set a envrionment when running tests. However there's a static field TestMockSupport.RunningMocked you can check.

In fact, I don't know why you change all the TestMockSupport.Delay() , that should work perfectly fine here

Copy link
Member

Choose a reason for hiding this comment

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

Besides, not only here, but all the "System.Threading.Sleep()should be wrapped in anIf` clause, otherwise the tests will still time out

Copy link
Member Author

Choose a reason for hiding this comment

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

@isra-fel : included "TestMockSupport.RunningMocked" and skipped two failed tests for now. I changed TestMockSupport.Delay() to Thread.Sleep() because while running the tests in record mode this was not putting a delay and was flooding our service with many calls. However it was working fine while running the cmdlets.

@isra-fel
Copy link
Member

Also, I tried to run the tests locally, there seem to be 2 cases still failling, needing to be recorded.

TestAzureVMSetVaultProperty in RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.cs
TestRecoveryServicesVaultCRUD in RecoveryServices.Test/ScenarioTests/RecoveryServicesTests.cs

Please either record them or skip.

@isra-fel
Copy link
Member

/azp run azure-powershell - powershell-core

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@isra-fel
Copy link
Member

CI stuck at generation test on MacOS. Last run was sucessful. It's OK to force merge.

@dolauli dolauli merged commit 4a33f21 into Azure:release-2020-12-29 Dec 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants