Skip to content

Feature/cplat msp compute #27936

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion src/Compute/Compute/Az.Compute.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ CmdletsToExport = 'Add-AzImageDataDisk', 'Add-AzVhd',
'Update-AzGalleryImageDefinition', 'Update-AzGalleryImageVersion',
'Update-AzHost', 'Update-AzImage', 'Update-AzRestorePointCollection',
'Update-AzSnapshot', 'Update-AzSshKey', 'Update-AzVM', 'Update-AzVmss',
'Update-AzVmssInstance', 'Update-AzVmssVM'
'Update-AzVmssInstance', 'Update-AzVmssVM', 'Set-AzVMProxyAgent', 'Set-AzVmssProxyAgent'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
6 changes: 6 additions & 0 deletions src/Compute/Compute/Common/ConstantStringTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ public static class ConstantValues
public const string TrustedLaunchDefaultHyperVGen = "v2";
}

public static class HyperVGenerations
{
public const string V1 = "V1";
public const string V2 = "V2";
}

public static class ProfileNouns
{
public const string VirtualMachineProfile = "AzureRmVMProfile";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// ----------------------------------------------------------------------------------
//
// 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.Commands.ResourceManager.Common.ArgumentCompleters;
using Microsoft.Azure.Management.Compute.Models;
using Microsoft.Azure.Commands.Compute.Automation.Models;

namespace Microsoft.Azure.Commands.Compute
{
[Cmdlet("Set", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VmssProxySetting"), OutputType(typeof(PSVirtualMachineScaleSet))]
public class SetAzureVmssProxySetting : Microsoft.Azure.Commands.ResourceManager.Common.AzureRMCmdlet
{
[Parameter(
Mandatory = true,
ValueFromPipeline = true,
ValueFromPipelineByPropertyName = true)]
public PSVirtualMachineScaleSet VirtualMachineScaleSet { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Specifies whether ProxyAgent feature should be enabled on the virtual machine or virtual machine scale set.")]
public SwitchParameter EnableProxyAgent { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Specifies the Wire Server endpoint execution mode while creating the virtual machine or virtual machine scale set. In Audit mode, the system acts as if it is enforcing the access control policy, including emitting access denial entries in the logs but it does not actually deny any requests to host endpoints. In Enforce mode, the system will enforce the access control and it is the recommended mode of operation.")]
[PSArgumentCompleter("Audit", "Enforce", "Disabled")]
public string WireServerMode { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Specifies the InVMAccessControlProfileVersion resource id in the Wire Server endpoint. Format of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles/{profile}/versions/{version}")]
public string WireServerProfile { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Specifies the IMDS endpoint execution mode. In Audit mode, the system acts as if it is enforcing the access control policy, including emitting access denial entries in the logs but it does not actually deny any requests to host endpoints. In Enforce mode, the system will enforce the access control and it is the recommended mode of operation.")]
[PSArgumentCompleter("Audit", "Enforce", "Disabled")]
public string ImdsMode { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Specifies the InVMAccessControlProfileVersion resource id in the IMDS enpoint. Format of /subscriptions/{SubscriptionId}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/inVMAccessControlProfiles/{profile}/versions/{version}")]
public string ImdsProfile { get; set; }

public override void ExecuteCmdlet()
{
if (this.VirtualMachineScaleSet.VirtualMachineProfile == null)
{
this.VirtualMachineScaleSet.VirtualMachineProfile = new PSVirtualMachineScaleSetVMProfile();
}
if (this.VirtualMachineScaleSet.VirtualMachineProfile.SecurityProfile == null)
{
this.VirtualMachineScaleSet.VirtualMachineProfile.SecurityProfile = new SecurityProfile();
}


this.VirtualMachineScaleSet.VirtualMachineProfile.SecurityProfile.ProxyAgentSettings = new ProxyAgentSettings
{
Enabled = this.EnableProxyAgent.IsPresent,
WireServer = (this.WireServerMode == null && this.WireServerProfile == null ? null : new HostEndpointSettings()
{
Mode = this.WireServerMode,
InVMAccessControlProfileReferenceId = this.WireServerProfile
}),
Imds = (this.ImdsMode == null && this.ImdsProfile == null ? null : new HostEndpointSettings()
{
Mode = this.ImdsMode,
InVMAccessControlProfileReferenceId = this.ImdsProfile
})
};

WriteObject(this.VirtualMachineScaleSet);
}
}

}
Loading