Skip to content

Commit 6e4a9c4

Browse files
authored
[AzureLoadTesting] New Module, commands for Azure Load Testing (#20385)
* init with readme * initial scaffolding for az.loadtesting * added examples, updated descriptions * added design review file * updated UAMI removal flow * workaround for nullable property issue * added tests updated tests * updated typos, generated review markdown * remove unused test files * updated tests * updated AKV dependent test to liveonly
1 parent 8943461 commit 6e4a9c4

37 files changed

+4156
-0
lines changed

src/LoadTesting/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

src/LoadTesting/.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
bin
2+
obj
3+
.vs
4+
generated
5+
internal
6+
exports
7+
tools
8+
custom/*.psm1
9+
custom/autogen-model-cmdlets
10+
test/*-TestResults.xml
11+
/*.ps1
12+
/*.ps1xml
13+
/*.psm1
14+
/*.snk
15+
/*.csproj
16+
/*.nuspec

src/LoadTesting/Az.LoadTesting.psd1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@{
2+
GUID = '739ddedf-3d49-40e0-bc84-00bedfe6b2ec'
3+
RootModule = './Az.LoadTesting.psm1'
4+
ModuleVersion = '0.1.0'
5+
CompatiblePSEditions = 'Core', 'Desktop'
6+
Author = 'Microsoft Corporation'
7+
CompanyName = 'Microsoft Corporation'
8+
Copyright = 'Microsoft Corporation. All rights reserved.'
9+
Description = 'Microsoft Azure PowerShell: LoadTesting cmdlets'
10+
PowerShellVersion = '5.1'
11+
DotNetFrameworkVersion = '4.7.2'
12+
RequiredAssemblies = './bin/Az.LoadTesting.private.dll'
13+
FormatsToProcess = './Az.LoadTesting.format.ps1xml'
14+
FunctionsToExport = 'Get-AzLoad', 'New-AzLoad', 'Remove-AzLoad', 'Update-AzLoad', '*'
15+
AliasesToExport = '*'
16+
PrivateData = @{
17+
PSData = @{
18+
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'LoadTesting'
19+
LicenseUri = 'https://aka.ms/azps-license'
20+
ProjectUri = 'https://github.com/Azure/azure-powershell'
21+
ReleaseNotes = ''
22+
}
23+
}
24+
}

src/LoadTesting/custom/Get-AzLoad.ps1

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
14+
# is regenerated.
15+
# ----------------------------------------------------------------------------------
16+
17+
<#
18+
.Synopsis
19+
Get the details of an Azure Load Testing resource.
20+
.Description
21+
Get the details of an Azure Load Testing resource.
22+
.Example
23+
{{ Add code here }}
24+
.Example
25+
{{ Add code here }}
26+
27+
.Outputs
28+
Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api20221201.ILoadTestResource
29+
.Link
30+
https://learn.microsoft.com/powershell/module/az.loadtesting/get-azload
31+
#>
32+
function Get-AzLoad {
33+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api20221201.ILoadTestResource])]
34+
[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)]
35+
param(
36+
[Parameter(ParameterSetName='Get', Mandatory)]
37+
[Alias('LoadTestName')]
38+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Path')]
39+
[System.String]
40+
# Name of the Azure Load Testing resource.
41+
${Name},
42+
43+
[Parameter(ParameterSetName='Get', Mandatory)]
44+
[Parameter(ParameterSetName='List1', Mandatory)]
45+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Path')]
46+
[System.String]
47+
# Name of the resource group.
48+
${ResourceGroupName},
49+
50+
[Parameter()]
51+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Path')]
52+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
53+
[System.String[]]
54+
# The ID of the subscription.
55+
${SubscriptionId},
56+
57+
[Parameter()]
58+
[Alias('AzureRMContext', 'AzureCredential')]
59+
[ValidateNotNull()]
60+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Azure')]
61+
[System.Management.Automation.PSObject]
62+
# The credentials, account, tenant, and subscription used for communication with Azure.
63+
${DefaultProfile},
64+
65+
[Parameter(DontShow)]
66+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
67+
[System.Management.Automation.SwitchParameter]
68+
# Wait for .NET debugger to attach
69+
${Break},
70+
71+
[Parameter(DontShow)]
72+
[ValidateNotNull()]
73+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
74+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.SendAsyncStep[]]
75+
# SendAsync Pipeline Steps to be appended to the front of the pipeline
76+
${HttpPipelineAppend},
77+
78+
[Parameter(DontShow)]
79+
[ValidateNotNull()]
80+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
81+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.SendAsyncStep[]]
82+
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
83+
${HttpPipelinePrepend},
84+
85+
[Parameter(DontShow)]
86+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
87+
[System.Uri]
88+
# The URI for the proxy server to use
89+
${Proxy},
90+
91+
[Parameter(DontShow)]
92+
[ValidateNotNull()]
93+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
94+
[System.Management.Automation.PSCredential]
95+
# Credentials for a proxy server to use for the remote call
96+
${ProxyCredential},
97+
98+
[Parameter(DontShow)]
99+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
100+
[System.Management.Automation.SwitchParameter]
101+
# Use the default credentials for the proxy
102+
${ProxyUseDefaultCredentials}
103+
)
104+
105+
process {
106+
try {
107+
Az.LoadTesting.internal\Get-AzLoad @PSBoundParameters
108+
}
109+
catch {
110+
throw
111+
}
112+
}
113+
}
114+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.
3+
// Code generated by Microsoft (R) AutoRest Code Generator.
4+
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
5+
6+
namespace Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api20221201
7+
{
8+
using static Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.Extensions;
9+
10+
public partial class EncryptionPropertiesIdentity
11+
{
12+
partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.Json.JsonObject container){
13+
if(string.Empty.Equals(this.ResourceId))
14+
{
15+
container.Remove("resourceId");
16+
container.Add("resourceId", Runtime.Json.XNull.Instance);
17+
}
18+
}
19+
}
20+
}

src/LoadTesting/custom/New-AzLoad.ps1

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
14+
# is regenerated.
15+
# ----------------------------------------------------------------------------------
16+
17+
<#
18+
.Synopsis
19+
Create a new Azure Load Testing resource.
20+
.Description
21+
Creates a new Azure Load Testing resource in the resource group.
22+
.Example
23+
{{ Add code here }}
24+
.Example
25+
{{ Add code here }}
26+
27+
.Outputs
28+
Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api20221201.ILoadTestResource
29+
.Link
30+
https://learn.microsoft.com/powershell/module/az.loadtesting/new-azload
31+
#>
32+
function New-AzLoad {
33+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api20221201.ILoadTestResource])]
34+
[CmdletBinding(PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')]
35+
param(
36+
[Parameter(Mandatory)]
37+
[Alias('LoadTestName')]
38+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Path')]
39+
[System.String]
40+
# Name of the new Azure Load Testing resource.
41+
${Name},
42+
43+
[Parameter(Mandatory)]
44+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Path')]
45+
[System.String]
46+
# Name of the resource group.
47+
${ResourceGroupName},
48+
49+
[Parameter(ParameterSetName='CreateExpanded')]
50+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Path')]
51+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
52+
[System.String]
53+
# The ID of the subscription.
54+
${SubscriptionId},
55+
56+
[Parameter(ParameterSetName='CreateExpanded', Mandatory)]
57+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Body')]
58+
[System.String]
59+
# Location where the Azure Load Testing resource needs to be created.
60+
${Location},
61+
62+
[Parameter(ParameterSetName='CreateExpanded')]
63+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Body')]
64+
[System.String]
65+
# The managed identity for Customer-managed key settings defining which identity should be used to authenticate to Key Vault.
66+
# Ex: '/subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/<resource group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId' uses the given user-assigned managed identity.
67+
${EncryptionIdentity},
68+
69+
[Parameter(ParameterSetName='CreateExpanded')]
70+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Body')]
71+
[System.String]
72+
# Encryption key URL, versioned.
73+
# Ex: https://contosovault.vault.azure.net/keys/contosokek/562a4bb76b524a1493a6afe8e536ee78.
74+
${EncryptionKey},
75+
76+
[Parameter(ParameterSetName='CreateExpanded')]
77+
[ArgumentCompleter([Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Support.ManagedServiceIdentityType])]
78+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Body')]
79+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Support.ManagedServiceIdentityType]
80+
# Type of managed identity.
81+
${IdentityType},
82+
83+
[Parameter(ParameterSetName='CreateExpanded')]
84+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Body')]
85+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api50.IUserAssignedIdentities]))]
86+
[System.Collections.Hashtable]
87+
# The list of user assigned identities associated with the resource. The user identity will be ARM resource ids.
88+
# 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}.
89+
# The values of the keys are empty objects ({}) in requests.
90+
${IdentityUserAssigned},
91+
92+
[Parameter(ParameterSetName='CreateExpanded')]
93+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Body')]
94+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Models.Api30.ITrackedResourceTags]))]
95+
[System.Collections.Hashtable]
96+
# Key-value pairs in the form of a hash table set as tags on the server. For example: @{key0="value0";key1=$null;key2="value2"}.
97+
${Tag},
98+
99+
[Parameter(ParameterSetName='CreateExpanded')]
100+
[Alias('AzureRMContext', 'AzureCredential')]
101+
[ValidateNotNull()]
102+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Azure')]
103+
[System.Management.Automation.PSObject]
104+
# The credentials, account, tenant, and subscription used for communication with Azure.
105+
${DefaultProfile},
106+
107+
[Parameter(ParameterSetName='CreateExpanded')]
108+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
109+
[System.Management.Automation.SwitchParameter]
110+
# Run the command as a job
111+
${AsJob},
112+
113+
[Parameter(ParameterSetName='CreateExpanded', DontShow)]
114+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
115+
[System.Management.Automation.SwitchParameter]
116+
# Wait for .NET debugger to attach
117+
${Break},
118+
119+
[Parameter(ParameterSetName='CreateExpanded', DontShow)]
120+
[ValidateNotNull()]
121+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
122+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.SendAsyncStep[]]
123+
# SendAsync Pipeline Steps to be appended to the front of the pipeline
124+
${HttpPipelineAppend},
125+
126+
[Parameter(ParameterSetName='CreateExpanded', DontShow)]
127+
[ValidateNotNull()]
128+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
129+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Runtime.SendAsyncStep[]]
130+
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
131+
${HttpPipelinePrepend},
132+
133+
[Parameter(ParameterSetName='CreateExpanded')]
134+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
135+
[System.Management.Automation.SwitchParameter]
136+
# Run the command asynchronously
137+
${NoWait},
138+
139+
[Parameter(ParameterSetName='CreateExpanded', DontShow)]
140+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
141+
[System.Uri]
142+
# The URI for the proxy server to use
143+
${Proxy},
144+
145+
[Parameter(ParameterSetName='CreateExpanded', DontShow)]
146+
[ValidateNotNull()]
147+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
148+
[System.Management.Automation.PSCredential]
149+
# Credentials for a proxy server to use for the remote call
150+
${ProxyCredential},
151+
152+
[Parameter(ParameterSetName='CreateExpanded', DontShow)]
153+
[Microsoft.Azure.PowerShell.Cmdlets.LoadTesting.Category('Runtime')]
154+
[System.Management.Automation.SwitchParameter]
155+
# Use the default credentials for the proxy
156+
${ProxyUseDefaultCredentials}
157+
)
158+
159+
process {
160+
try {
161+
# if encyyption identity has a value, populate the encryption identity type and encryption identity resource id
162+
# add the managed identity to the list of user assigned identities
163+
if ($PSBoundParameters.ContainsKey('EncryptionIdentity')) {
164+
$null = $PSBoundParameters.Add("EncryptionIdentityResourceId", $PSBoundParameters['EncryptionIdentity'])
165+
$null = $PSBoundParameters.Add("EncryptionIdentityType", 'UserAssigned')
166+
$null = $PSBoundParameters.Remove('EncryptionIdentity')
167+
168+
# Update the identity type
169+
if($PSBoundParameters.ContainsKey('IdentityType')) {
170+
if($PSBoundParameters['IdentityType'].ToString().ToLower() -eq 'none') {
171+
$null = $PSBoundParameters.Add("IdentityType", 'UserAssigned')
172+
}
173+
elseif($PSBoundParameters['IdentityType'].ToString().ToLower() -eq 'systemassigned') {
174+
$null = $PSBoundParameters.Add("IdentityType", 'SystemAssigned,UserAssigned')
175+
}
176+
}
177+
else {
178+
$null = $PSBoundParameters.Add("IdentityType", 'UserAssigned')
179+
}
180+
181+
# Update the User Assigned Identities
182+
if ($PSBoundParameters.ContainsKey('IdentityUserAssigned')) {
183+
if ($null -eq $PSBoundParameters['IdentityUserAssigned']){
184+
$PSBoundParameters['IdentityUserAssigned'] = @{}
185+
}
186+
$PSBoundParameters['IdentityUserAssigned'][$PSBoundParameters['EncryptionIdentityResourceId']] = @{}
187+
}
188+
else {
189+
$null = $PSBoundParameters.Add("IdentityUserAssigned", @{ $PSBoundParameters['EncryptionIdentityResourceId'] = @{} })
190+
}
191+
}
192+
Az.LoadTesting.internal\New-AzLoad @PSBoundParameters
193+
}
194+
catch {
195+
throw
196+
}
197+
}
198+
}

0 commit comments

Comments
 (0)