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