From fd05db86851e19e1b284cadb4a50df564c16afeb Mon Sep 17 00:00:00 2001 From: Theodore Chang Date: Wed, 31 Aug 2022 21:56:51 -0400 Subject: [PATCH] gallery Confidential VM feature (#19359) * update sdk package * implement * suppress breaking change * update md file and changelog * Fix ps730previewbug (#19351) * update sdk package * suppress breaking change Co-authored-by: Theodore Chang * Update src/RecoveryServices/RecoveryServices.SiteRecovery.Test/RecoveryServices.SiteRecovery.Test.csproj * suppress example issues * fix example issues * example and changelog Co-authored-by: Theodore Chang Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> --- src/Compute/Compute/ChangeLog.md | 1 + ...GalleryImageVersionCreateOrUpdateMethod.cs | 28 +++++++++++++++++++ .../help/New-AzGalleryImageDefinition.md | 5 ++-- .../Compute/help/New-AzGalleryImageVersion.md | 3 +- .../Exceptions/Az.Compute/ExampleIssues.csv | 8 ++++++ 5 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 tools/StaticAnalysis/Exceptions/Az.Compute/ExampleIssues.csv diff --git a/src/Compute/Compute/ChangeLog.md b/src/Compute/Compute/ChangeLog.md index bc5b76dc38d4..1661cb912f44 100644 --- a/src/Compute/Compute/ChangeLog.md +++ b/src/Compute/Compute/ChangeLog.md @@ -27,6 +27,7 @@ * Improved printed output for `Get-AzComputeResourceSku` * Updated `Update-AzVm` to give constructive error messages when empty variables are passed in parameters. [#15081] * Added `Zone` and `IntentVMSizeList` optional parameters to the cmdlet `New-AzProximityPlacementGroup`. +* For `New-AzGalleryImageVersion`, `CVMEncryptionType` and `CVMDiskEncryptionSetID` added as keys for parameter `-Target`. ## Version 4.30.0 * Added parameters `PackageFileName`, `ConfigFileName` for `New-AzGalleryApplicationVersion` diff --git a/src/Compute/Compute/Generated/GalleryImageVersion/GalleryImageVersionCreateOrUpdateMethod.cs b/src/Compute/Compute/Generated/GalleryImageVersion/GalleryImageVersionCreateOrUpdateMethod.cs index 795e717574e1..8246a8c6c5d8 100644 --- a/src/Compute/Compute/Generated/GalleryImageVersion/GalleryImageVersionCreateOrUpdateMethod.cs +++ b/src/Compute/Compute/Generated/GalleryImageVersion/GalleryImageVersionCreateOrUpdateMethod.cs @@ -147,6 +147,34 @@ public override void ExecuteCmdlet() target.Encryption = new EncryptionImages(osDiskImageEncryption, dataDiskImageEncryption); } + if (t["CVMEncryptionType"] != null) + { + if (target.Encryption == null) + { + target.Encryption = new EncryptionImages(); + } + target.Encryption.OsDiskImage = new OSDiskImageEncryption(); + target.Encryption.OsDiskImage.SecurityProfile = new OSDiskImageSecurityProfile(); + target.Encryption.OsDiskImage.SecurityProfile.ConfidentialVMEncryptionType = (string)t["CVMEncryptionType"]; + } + + if (t["CVMDiskEncryptionSetID"] != null) + { + if (target.Encryption == null) + { + target.Encryption = new EncryptionImages(); + } + if (target.Encryption.OsDiskImage == null) + { + target.Encryption.OsDiskImage = new OSDiskImageEncryption(); + } + if (target.Encryption.OsDiskImage.SecurityProfile == null) + { + target.Encryption.OsDiskImage.SecurityProfile = new OSDiskImageSecurityProfile(); + } + target.Encryption.OsDiskImage.SecurityProfile.SecureVMDiskEncryptionSetId = (string)t["CVMDiskEncryptionSetID"]; + } + galleryImageVersion.PublishingProfile.TargetRegions.Add(target); } } diff --git a/src/Compute/Compute/help/New-AzGalleryImageDefinition.md b/src/Compute/Compute/help/New-AzGalleryImageDefinition.md index d51b875f5fcf..b3436af44250 100644 --- a/src/Compute/Compute/help/New-AzGalleryImageDefinition.md +++ b/src/Compute/Compute/help/New-AzGalleryImageDefinition.md @@ -1,4 +1,4 @@ ---- +--- external help file: Microsoft.Azure.PowerShell.Cmdlets.Compute.dll-Help.xml Module Name: Az.Compute online version: https://docs.microsoft.com/powershell/module/az.compute/new-azgalleryimagedefinition @@ -91,7 +91,8 @@ $skuName = "GreatSku" $description = "My gallery" $IsHibernateSupported = @{Name='IsHibernateSupported';Value='True'} $IsAcceleratedNetworkSupported = @{Name='IsAcceleratedNetworkSupported';Value='False'} -$features = @($IsHibernateSupported,$IsAcceleratedNetworkSupported) +$ConfidentialVMSupported = @{Name='SecurityType';Value='ConfidentialVMSupported'} +$features = @($IsHibernateSupported,$IsAcceleratedNetworkSupported, $ConfidentialVMSupported) New-AzGalleryImageDefinition -ResourceGroupName $rgName -GalleryName $galleryName -Name $galleryImageDefinitionName -Location $location -Publisher $publisherName -Offer $offerName -Sku $skuName -OsState "Generalized" -OsType "Windows" -Description $description -Feature $features ``` diff --git a/src/Compute/Compute/help/New-AzGalleryImageVersion.md b/src/Compute/Compute/help/New-AzGalleryImageVersion.md index 4b06e46da9c6..5edb3c510c26 100644 --- a/src/Compute/Compute/help/New-AzGalleryImageVersion.md +++ b/src/Compute/Compute/help/New-AzGalleryImageVersion.md @@ -155,9 +155,10 @@ $galleryImageDefinitionName = "myImage" $galleryImageVersionName = "1.0.0" $location = "eastus" $sourceImageId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myVMRG/providers/Microsoft.Compute/virtualMachines/myVM" +$diskEncryptionSetId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myVMRG/providers/Microsoft.Compute/diskEncryptionSets/cvmDiskEncryptionSet" $replicaCount = 1 $storageAccountType = "Standard_ZRS" -$region_eastus = @{Name = 'East US';ReplicaCount = 3;StorageAccountType = 'Standard_LRS'} +$region_eastus = @{Name = 'East US';ReplicaCount = 3;StorageAccountType = 'Standard_LRS'; CVMEncryptionType="EncryptedWithCmk"; CVMDiskEncryptionSetID=$diskEncryptionSetId} $region_westus = @{Name = 'West US'} $region_ukwest = @{Name = 'UK West';ReplicaCount = 2} $region_southcentralus = @{Name = 'South Central US';StorageAccountType = 'Standard_LRS'} diff --git a/tools/StaticAnalysis/Exceptions/Az.Compute/ExampleIssues.csv b/tools/StaticAnalysis/Exceptions/Az.Compute/ExampleIssues.csv new file mode 100644 index 000000000000..27ab3cd4d709 --- /dev/null +++ b/tools/StaticAnalysis/Exceptions/Az.Compute/ExampleIssues.csv @@ -0,0 +1,8 @@ +"Module","Cmdlet","Example","Line","RuleName","ProblemId","Severity","Description","Extent","Remediation" +"Compute","New-AzGalleryImageDefinition","4","11","MissingEndCurlyBrace","5200","1","Missing closing '}' in statement block or type definition.","","Unexpected Error. Please check [Trouble Shotting for Unexpected Errors in Example Issues](https://github.com/Azure/azure-powershell/blob/main/documentation/Debugging-StaticAnalysis-Errors.md#Troubleshotting-Example-Issues) for more details." +"Compute","New-AzGalleryImageDefinition","4","11","UnexpectedToken","5200","1","Unexpected token '?????Name='SecurityType'' in expression or statement.","?????Name='SecurityType'","Unexpected Error. Please check [Trouble Shotting for Unexpected Errors in Example Issues](https://github.com/Azure/azure-powershell/blob/main/documentation/Debugging-StaticAnalysis-Errors.md#Troubleshotting-Example-Issues) for more details." +"Compute","New-AzGalleryImageDefinition","4","14","UnexpectedToken","5200","1","Unexpected token '}' in expression or statement.","}","Unexpected Error. Please check [Trouble Shotting for Unexpected Errors in Example Issues](https://github.com/Azure/azure-powershell/blob/main/documentation/Debugging-StaticAnalysis-Errors.md#Troubleshotting-Example-Issues) for more details." +"Compute","New-AzGalleryImageDefinition","4","11","Invalid_Cmdlet","5000","1","????? is not a valid command name.","?????","Check the spell of ?????." +"Compute","New-AzGalleryImageDefinition","4","11","Invalid_Cmdlet","5000","1","?????Name='SecurityType' is not a valid command name.","?????Name='SecurityType'","Check the spell of ?????Name='SecurityType'." +"Compute","New-AzGalleryImageDefinition","4","11","Invalid_Cmdlet","5000","1","Value='ConfidentialVMSupported' is not a valid command name.","Value='ConfidentialVMSupported'","Check the spell of Value='ConfidentialVMSupported'." +"Compute","New-AzGalleryImageVersion","9","10","Invalid_Cmdlet","5000","1","EncryptedWithCmk is not a valid command name.","EncryptedWithCmk","Check the spell of EncryptedWithCmk." \ No newline at end of file