Skip to content

[AzureLoadTesting] New Module, commands for Azure Load Testing #20385

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 11 commits into from
Jan 5, 2023
Merged
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
1 change: 1 addition & 0 deletions src/LoadTesting/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
16 changes: 16 additions & 0 deletions src/LoadTesting/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
bin
obj
.vs
generated
internal
exports
tools
custom/*.psm1
custom/autogen-model-cmdlets
test/*-TestResults.xml
/*.ps1
/*.ps1xml
/*.psm1
/*.snk
/*.csproj
/*.nuspec
24 changes: 24 additions & 0 deletions src/LoadTesting/Az.LoadTesting.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@{
GUID = '739ddedf-3d49-40e0-bc84-00bedfe6b2ec'
RootModule = './Az.LoadTesting.psm1'
ModuleVersion = '0.1.0'
CompatiblePSEditions = 'Core', 'Desktop'
Author = 'Microsoft Corporation'
CompanyName = 'Microsoft Corporation'
Copyright = 'Microsoft Corporation. All rights reserved.'
Description = 'Microsoft Azure PowerShell: LoadTesting cmdlets'
PowerShellVersion = '5.1'
DotNetFrameworkVersion = '4.7.2'
RequiredAssemblies = './bin/Az.LoadTesting.private.dll'
FormatsToProcess = './Az.LoadTesting.format.ps1xml'
FunctionsToExport = 'Get-AzLoad', 'New-AzLoad', 'Remove-AzLoad', 'Update-AzLoad', '*'
AliasesToExport = '*'
PrivateData = @{
PSData = @{
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'LoadTesting'
LicenseUri = 'https://aka.ms/azps-license'
ProjectUri = 'https://github.com/Azure/azure-powershell'
ReleaseNotes = ''
}
}
}
114 changes: 114 additions & 0 deletions src/LoadTesting/custom/Get-AzLoad.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@

# ----------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# 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.
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
# is regenerated.
# ----------------------------------------------------------------------------------

<#
.Synopsis
Get the details of an Azure Load Testing resource.
.Description
Get the details of an Azure Load Testing resource.
.Example
{{ Add code here }}
.Example
{{ Add code here }}

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api20221201.ILoadTestResource
.Link
https://learn.microsoft.com/powershell/module/az.loadtesting/get-azload
#>
function Get-AzLoad {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api20221201.ILoadTestResource])]
[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)]
param(
[Parameter(ParameterSetName='Get', Mandatory)]
[Alias('LoadTestName')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Path')]
[System.String]
# Name of the Azure Load Testing resource.
${Name},

[Parameter(ParameterSetName='Get', Mandatory)]
[Parameter(ParameterSetName='List1', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Path')]
[System.String]
# Name of the resource group.
${ResourceGroupName},

[Parameter()]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
[System.String[]]
# The ID of the subscription.
${SubscriptionId},

[Parameter()]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Azure')]
[System.Management.Automation.PSObject]
# The credentials, account, tenant, and subscription used for communication with Azure.
${DefaultProfile},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Wait for .NET debugger to attach
${Break},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be appended to the front of the pipeline
${HttpPipelineAppend},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
${HttpPipelinePrepend},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[System.Uri]
# The URI for the proxy server to use
${Proxy},

[Parameter(DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[System.Management.Automation.PSCredential]
# Credentials for a proxy server to use for the remote call
${ProxyCredential},

[Parameter(DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Use the default credentials for the proxy
${ProxyUseDefaultCredentials}
)

process {
try {
Az.LoadTesting.internal\Get-AzLoad @PSBoundParameters
}
catch {
throw
}
}
}

20 changes: 20 additions & 0 deletions src/LoadTesting/custom/LoadTestResourceCustom.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.

namespace Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api20221201
{
using static Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.Extensions;

public partial class EncryptionPropertiesIdentity
{
partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.Json.JsonObject container){
if(string.Empty.Equals(this.ResourceId))
{
container.Remove("resourceId");
container.Add("resourceId", Runtime.Json.XNull.Instance);
}
}
}
}
198 changes: 198 additions & 0 deletions src/LoadTesting/custom/New-AzLoad.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@

# ----------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# 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.
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
# is regenerated.
# ----------------------------------------------------------------------------------

<#
.Synopsis
Create a new Azure Load Testing resource.
.Description
Creates a new Azure Load Testing resource in the resource group.
.Example
{{ Add code here }}
.Example
{{ Add code here }}

.Outputs
Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api20221201.ILoadTestResource
.Link
https://learn.microsoft.com/powershell/module/az.loadtesting/new-azload
#>
function New-AzLoad {
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api20221201.ILoadTestResource])]
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
param(
[Parameter(Mandatory)]
[Alias('LoadTestName')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Path')]
[System.String]
# Name of the new Azure Load Testing resource.
${Name},

[Parameter(Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Path')]
[System.String]
# Name of the resource group.
${ResourceGroupName},

[Parameter(ParameterSetName='CreateExpanded')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Path')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
[System.String]
# The ID of the subscription.
${SubscriptionId},

[Parameter(ParameterSetName='CreateExpanded', Mandatory)]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Body')]
[System.String]
# Location where the Azure Load Testing resource needs to be created.
${Location},

[Parameter(ParameterSetName='CreateExpanded')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Body')]
[System.String]
# The managed identity for Customer-managed key settings defining which identity should be used to authenticate to Key Vault.
# Ex: '/subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/<resource group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId' uses the given user-assigned managed identity.
${EncryptionIdentity},

[Parameter(ParameterSetName='CreateExpanded')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Body')]
[System.String]
# Encryption key URL, versioned.
# Ex: https://contosovault.vault.azure.net/keys/contosokek/562a4bb76b524a1493a6afe8e536ee78.
${EncryptionKey},

[Parameter(ParameterSetName='CreateExpanded')]
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Support.ManagedServiceIdentityType])]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Support.ManagedServiceIdentityType]
# Type of managed identity.
${IdentityType},

[Parameter(ParameterSetName='CreateExpanded')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api50.IUserAssignedIdentities]))]
[System.Collections.Hashtable]
# The list of user assigned identities associated with the resource. The user identity will be ARM resource ids.
# The User Assigned Identity is a hashtable with keys in the form of an ARM resource id '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.
# The values of the keys are empty objects ({}) in requests.
${IdentityUserAssigned},

[Parameter(ParameterSetName='CreateExpanded')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Body')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api30.ITrackedResourceTags]))]
[System.Collections.Hashtable]
# Key-value pairs in the form of a hash table set as tags on the server. For example: @{key0="value0";key1=$null;key2="value2"}.
${Tag},

[Parameter(ParameterSetName='CreateExpanded')]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Azure')]
[System.Management.Automation.PSObject]
# The credentials, account, tenant, and subscription used for communication with Azure.
${DefaultProfile},

[Parameter(ParameterSetName='CreateExpanded')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Run the command as a job
${AsJob},

[Parameter(ParameterSetName='CreateExpanded', DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Wait for .NET debugger to attach
${Break},

[Parameter(ParameterSetName='CreateExpanded', DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be appended to the front of the pipeline
${HttpPipelineAppend},

[Parameter(ParameterSetName='CreateExpanded', DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.SendAsyncStep[]]
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
${HttpPipelinePrepend},

[Parameter(ParameterSetName='CreateExpanded')]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Run the command asynchronously
${NoWait},

[Parameter(ParameterSetName='CreateExpanded', DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[System.Uri]
# The URI for the proxy server to use
${Proxy},

[Parameter(ParameterSetName='CreateExpanded', DontShow)]
[ValidateNotNull()]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[System.Management.Automation.PSCredential]
# Credentials for a proxy server to use for the remote call
${ProxyCredential},

[Parameter(ParameterSetName='CreateExpanded', DontShow)]
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
[System.Management.Automation.SwitchParameter]
# Use the default credentials for the proxy
${ProxyUseDefaultCredentials}
)

process {
try {
# if encyyption identity has a value, populate the encryption identity type and encryption identity resource id
# add the managed identity to the list of user assigned identities
if ($PSBoundParameters.ContainsKey('EncryptionIdentity')) {
$null = $PSBoundParameters.Add("EncryptionIdentityResourceId", $PSBoundParameters['EncryptionIdentity'])
$null = $PSBoundParameters.Add("EncryptionIdentityType", 'UserAssigned')
$null = $PSBoundParameters.Remove('EncryptionIdentity')

# Update the identity type
if($PSBoundParameters.ContainsKey('IdentityType')) {
if($PSBoundParameters['IdentityType'].ToString().ToLower() -eq 'none') {
$null = $PSBoundParameters.Add("IdentityType", 'UserAssigned')
}
elseif($PSBoundParameters['IdentityType'].ToString().ToLower() -eq 'systemassigned') {
$null = $PSBoundParameters.Add("IdentityType", 'SystemAssigned,UserAssigned')
}
}
else {
$null = $PSBoundParameters.Add("IdentityType", 'UserAssigned')
}

# Update the User Assigned Identities
if ($PSBoundParameters.ContainsKey('IdentityUserAssigned')) {
if ($null -eq $PSBoundParameters['IdentityUserAssigned']){
$PSBoundParameters['IdentityUserAssigned'] = @{}
}
$PSBoundParameters['IdentityUserAssigned'][$PSBoundParameters['EncryptionIdentityResourceId']] = @{}
}
else {
$null = $PSBoundParameters.Add("IdentityUserAssigned", @{ $PSBoundParameters['EncryptionIdentityResourceId'] = @{} })
}
}
Az.LoadTesting.internal\New-AzLoad @PSBoundParameters
}
catch {
throw
}
}
}
Loading