Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

-->
## Upcoming Release
* Updated `Set-AzDiskSecurityProfile` cmdlet
- The existing parameter SecurityType is now set to null after processing the user's input value.
* Fixed `New-AzVmss` to correctly work when using `-EdgeZone` by creating the Load Balancer in the correct edge zone.
* Removed references to image aliases in `New-AzVM` and `New-AzVmss` to images that were removed.
* Fixed `New-AzVmss` to correctly work when using `-EdgeZone` by creating the Load Balancer in the correct edge zone.
* Removed references to image aliases in `New-AzVM` and `New-AzVmss` to images that were removed.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,101 +0,0 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------


using System;
using System.Collections.Generic;
using System.Text;
using System.Management.Automation;
using Microsoft.Azure.Commands.Compute.Common;
using Microsoft.Azure.Commands.Compute.Models;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Azure.Commands.Compute.Automation.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

namespace Microsoft.Azure.Commands.Compute
{
[Cmdlet("Set", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "DiskSecurityProfile", SupportsShouldProcess = true)]
[OutputType(typeof(PSDisk))]
public class SetAzDiskSecurityProfile : Microsoft.Azure.Commands.ResourceManager.Common.AzureRMCmdlet
{
[Alias("DiskSecurityProfile")]
[Parameter(
Mandatory = true,
Position = 0,
ValueFromPipeline = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Disk Security Profile")]
[ValidateNotNullOrEmpty]
public PSDisk Disk { get; set; }

[Parameter(
Mandatory = true,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Gets or sets the SecurityType property. Possible values include: TrustedLaunch, ConfidentialVM_DiskEncryptedWithCustomerKey, ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey, ConfidentialVM_DiskEncryptedWithPlatformKey")]
[PSArgumentCompleter("Standard", "TrustedLaunch", "ConfidentialVM_DiskEncryptedWithCustomerKey", "ConfidentialVM_VMGuestStateOnlyEncryptedWithPlatformKey",
"ConfidentialVM_DiskEncryptedWithPlatformKey")]
public string SecurityType { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "ResourceId of the disk encryption set to use for enabling encryption at rest.")]
public string SecureVMDiskEncryptionSet { get; set; }

protected override void ProcessRecord()
{
if (ShouldProcess("DiskSecurityProfile", "Set"))
{
Run();
}
}

private void Run()
{
// At this time, it is impossible to set SecurityType to Standard ("") as it is a mandatory property on the backend.
// If Standard is used, then there should be no securityProfile at all for now.
if (SecurityType.ToLower() != ConstantValues.StandardSecurityType)
{
if(this.Disk.SecurityProfile == null)
{
this.Disk.SecurityProfile = new DiskSecurityProfile();
}
this.Disk.SecurityProfile.SecurityType = SecurityType;
}

// Allow the Standard scenario, which will be nulled out just before the .Net SDK create call for disks.
if (SecurityType.ToLower() == ConstantValues.StandardSecurityType)
{
if (this.Disk.SecurityProfile == null)
{
this.Disk.SecurityProfile = new DiskSecurityProfile();
}
this.Disk.SecurityProfile.SecurityType = SecurityType;
}

if (this.IsParameterBound(c => c.SecureVMDiskEncryptionSet))
{
if (this.Disk.SecurityProfile == null)
{
this.Disk.SecurityProfile = new DiskSecurityProfile();
}
this.Disk.SecurityProfile.SecureVMDiskEncryptionSetId = this.SecureVMDiskEncryptionSet;
}

WriteObject(this.Disk);
}
}

}