|
| 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 | +Update a Virtual Instance for SAP solutions resource |
| 20 | +.Description |
| 21 | +Update a Virtual Instance for SAP solutions resource |
| 22 | +.Example |
| 23 | +{{ Add code here }} |
| 24 | +.Example |
| 25 | +{{ Add code here }} |
| 26 | +
|
| 27 | +.Inputs |
| 28 | +Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.ISapVirtualInstanceIdentity |
| 29 | +.Outputs |
| 30 | +Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.ISapVirtualInstance |
| 31 | +.Notes |
| 32 | +COMPLEX PARAMETER PROPERTIES |
| 33 | +
|
| 34 | +To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables. |
| 35 | +
|
| 36 | +INPUTOBJECT <ISapVirtualInstanceIdentity>: Identity Parameter |
| 37 | + [ApplicationInstanceName <String>]: The name of SAP Application Server instance resource. |
| 38 | + [CentralInstanceName <String>]: Central Services Instance resource name string modeled as parameter for auto generation to work correctly. |
| 39 | + [DatabaseInstanceName <String>]: Database resource name string modeled as parameter for auto generation to work correctly. |
| 40 | + [Id <String>]: Resource identity path |
| 41 | + [Location <String>]: The name of the Azure region. |
| 42 | + [ResourceGroupName <String>]: The name of the resource group. The name is case insensitive. |
| 43 | + [SapVirtualInstanceName <String>]: The name of the Virtual Instances for SAP solutions resource |
| 44 | + [SubscriptionId <String>]: The ID of the target subscription. The value must be an UUID. |
| 45 | +.Link |
| 46 | +https://learn.microsoft.com/powershell/module/az.workloads/update-azworkloadssapvirtualinstance |
| 47 | +#> |
| 48 | +function Update-AzWorkloadsSapVirtualInstance { |
| 49 | +[Alias('Update-AzVIS')] |
| 50 | +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.ISapVirtualInstance])] |
| 51 | +[CmdletBinding(DefaultParameterSetName='UpdateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] |
| 52 | +param( |
| 53 | + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] |
| 54 | + [Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)] |
| 55 | + [Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)] |
| 56 | + [Alias('SapVirtualInstanceName')] |
| 57 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Path')] |
| 58 | + [System.String] |
| 59 | + # The name of the Virtual Instances for SAP solutions resource |
| 60 | + ${Name}, |
| 61 | + |
| 62 | + [Parameter(ParameterSetName='UpdateExpanded', Mandatory)] |
| 63 | + [Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)] |
| 64 | + [Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)] |
| 65 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Path')] |
| 66 | + [System.String] |
| 67 | + # The name of the resource group. |
| 68 | + # The name is case insensitive. |
| 69 | + ${ResourceGroupName}, |
| 70 | + |
| 71 | + [Parameter(ParameterSetName='UpdateExpanded')] |
| 72 | + [Parameter(ParameterSetName='UpdateViaJsonFilePath')] |
| 73 | + [Parameter(ParameterSetName='UpdateViaJsonString')] |
| 74 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Path')] |
| 75 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] |
| 76 | + [System.String] |
| 77 | + # The ID of the target subscription. |
| 78 | + # The value must be an UUID. |
| 79 | + ${SubscriptionId}, |
| 80 | + |
| 81 | + [Parameter(ParameterSetName='UpdateViaIdentityExpanded', Mandatory, ValueFromPipeline)] |
| 82 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Path')] |
| 83 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.ISapVirtualInstanceIdentity] |
| 84 | + # Identity Parameter |
| 85 | + ${InputObject}, |
| 86 | + |
| 87 | + [Parameter(ParameterSetName = 'UpdateExpanded')] |
| 88 | + [Parameter(ParameterSetName = 'UpdateViaIdentityExpanded')] |
| 89 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Body')] |
| 90 | + [System.Nullable[System.Boolean]] |
| 91 | + # Determines whether to enable a system-assigned identity for the resource. |
| 92 | + ${EnableSystemAssignedIdentity}, |
| 93 | + |
| 94 | + [Parameter(ParameterSetName='UpdateExpanded')] |
| 95 | + [Parameter(ParameterSetName='UpdateViaIdentityExpanded')] |
| 96 | + [AllowEmptyCollection()] |
| 97 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Body')] |
| 98 | + [System.String[]] |
| 99 | + # The array of user assigned identities associated with the resource. |
| 100 | + # The elements in array will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.' |
| 101 | + ${UserAssignedIdentity}, |
| 102 | + |
| 103 | + [Parameter(ParameterSetName='UpdateExpanded')] |
| 104 | + [Parameter(ParameterSetName='UpdateViaIdentityExpanded')] |
| 105 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.PSArgumentCompleterAttribute("Public", "Private")] |
| 106 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Body')] |
| 107 | + [System.String] |
| 108 | + # Specifies the network access configuration for the resources that will be deployed in the Managed Resource Group. |
| 109 | + # The options to choose from are Public and Private. |
| 110 | + # If 'Private' is chosen, the Storage Account service tag should be enabled on the subnets in which the SAP VMs exist. |
| 111 | + # This is required for establishing connectivity between VM extensions and the managed resource group storage account. |
| 112 | + # This setting is currently applicable only to Storage Account. |
| 113 | + # Learn more here https://go.microsoft.com/fwlink/?linkid=2247228 |
| 114 | + ${ManagedResourcesNetworkAccessType}, |
| 115 | + |
| 116 | + [Parameter(ParameterSetName='UpdateExpanded')] |
| 117 | + [Parameter(ParameterSetName='UpdateViaIdentityExpanded')] |
| 118 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Body')] |
| 119 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Runtime.Info(PossibleTypes=([Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.IUpdateSapVirtualInstanceRequestTags]))] |
| 120 | + [System.Collections.Hashtable] |
| 121 | + # Gets or sets the Resource tags. |
| 122 | + ${Tag}, |
| 123 | + |
| 124 | + [Parameter(ParameterSetName='UpdateViaJsonFilePath', Mandatory)] |
| 125 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Body')] |
| 126 | + [System.String] |
| 127 | + # Path of Json file supplied to the Update operation |
| 128 | + ${JsonFilePath}, |
| 129 | + |
| 130 | + [Parameter(ParameterSetName='UpdateViaJsonString', Mandatory)] |
| 131 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Body')] |
| 132 | + [System.String] |
| 133 | + # Json string supplied to the Update operation |
| 134 | + ${JsonString}, |
| 135 | + |
| 136 | + [Parameter()] |
| 137 | + [Alias('AzureRMContext', 'AzureCredential')] |
| 138 | + [ValidateNotNull()] |
| 139 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Azure')] |
| 140 | + [System.Management.Automation.PSObject] |
| 141 | + # The DefaultProfile parameter is not functional. |
| 142 | + # Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription. |
| 143 | + ${DefaultProfile}, |
| 144 | + |
| 145 | + [Parameter()] |
| 146 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')] |
| 147 | + [System.Management.Automation.SwitchParameter] |
| 148 | + # Run the command as a job |
| 149 | + ${AsJob}, |
| 150 | + |
| 151 | + [Parameter(DontShow)] |
| 152 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')] |
| 153 | + [System.Management.Automation.SwitchParameter] |
| 154 | + # Wait for .NET debugger to attach |
| 155 | + ${Break}, |
| 156 | + |
| 157 | + [Parameter(DontShow)] |
| 158 | + [ValidateNotNull()] |
| 159 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')] |
| 160 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Runtime.SendAsyncStep[]] |
| 161 | + # SendAsync Pipeline Steps to be appended to the front of the pipeline |
| 162 | + ${HttpPipelineAppend}, |
| 163 | + |
| 164 | + [Parameter(DontShow)] |
| 165 | + [ValidateNotNull()] |
| 166 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')] |
| 167 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Runtime.SendAsyncStep[]] |
| 168 | + # SendAsync Pipeline Steps to be prepended to the front of the pipeline |
| 169 | + ${HttpPipelinePrepend}, |
| 170 | + |
| 171 | + [Parameter()] |
| 172 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')] |
| 173 | + [System.Management.Automation.SwitchParameter] |
| 174 | + # Run the command asynchronously |
| 175 | + ${NoWait}, |
| 176 | + |
| 177 | + [Parameter(DontShow)] |
| 178 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')] |
| 179 | + [System.Uri] |
| 180 | + # The URI for the proxy server to use |
| 181 | + ${Proxy}, |
| 182 | + |
| 183 | + [Parameter(DontShow)] |
| 184 | + [ValidateNotNull()] |
| 185 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')] |
| 186 | + [System.Management.Automation.PSCredential] |
| 187 | + # Credentials for a proxy server to use for the remote call |
| 188 | + ${ProxyCredential}, |
| 189 | + |
| 190 | + [Parameter(DontShow)] |
| 191 | + [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Category('Runtime')] |
| 192 | + [System.Management.Automation.SwitchParameter] |
| 193 | + # Use the default credentials for the proxy |
| 194 | + ${ProxyUseDefaultCredentials} |
| 195 | +) |
| 196 | +process { |
| 197 | + if ($PSBoundParameters.ContainsKey('EnableSystemAssignedIdentity') -or $PSBoundParameters.ContainsKey('UserAssignedIdentity') ) { |
| 198 | + |
| 199 | + $EnvPSBoundParameters = @{} |
| 200 | + if ($PSBoundParameters.ContainsKey('Debug')) { |
| 201 | + $EnvPSBoundParameters['Debug'] = $Debug |
| 202 | + } |
| 203 | + if ($PSBoundParameters.ContainsKey('HttpPipelineAppend')) { |
| 204 | + $EnvPSBoundParameters['HttpPipelineAppend'] = $HttpPipelineAppend |
| 205 | + } |
| 206 | + if ($PSBoundParameters.ContainsKey('HttpPipelinePrepend')) { |
| 207 | + $EnvPSBoundParameters['HttpPipelinePrepend'] = $HttpPipelinePrepend |
| 208 | + } |
| 209 | + if ($PSBoundParameters.ContainsKey('Proxy')) { |
| 210 | + $EnvPSBoundParameters['Proxy'] = $Proxy |
| 211 | + } |
| 212 | + if ($PSBoundParameters.ContainsKey('ProxyCredential')) { |
| 213 | + $EnvPSBoundParameters['ProxyCredential'] = $ProxyCredential |
| 214 | + } |
| 215 | + if ($PSBoundParameters.ContainsKey('ProxyUseDefaultCredentials')) { |
| 216 | + $EnvPSBoundParameters['ProxyUseDefaultCredentials'] = $ProxyUseDefaultCredentials |
| 217 | + } |
| 218 | + if ($PSBoundParameters.ContainsKey('DefaultProfile')) { |
| 219 | + $EnvPSBoundParameters['DefaultProfile'] = $DefaultProfile |
| 220 | + } |
| 221 | + |
| 222 | + # Get SAPVirtualInstance DataObj |
| 223 | + $parameterSet = $PSCmdlet.ParameterSetName |
| 224 | + if (('UpdateExpanded') -contains $parameterSet) { |
| 225 | + $SapVirtualInstanceObj = Az.SapVirtualInstance.private\Get-AzWorkloadsSapVirtualInstance_Get -Name $Name -ResourceGroupName $ResourceGroupName -SubscriptionId $SubscriptionId @EnvPSBoundParameters |
| 226 | + } |
| 227 | + elseif (('UpdateViaIdentityExpanded') -contains $parameterSet) { |
| 228 | + $SapVirtualInstanceObj = Az.SapVirtualInstance.private\Get-AzWorkloadsSapVirtualInstance_GetViaIdentity -InputObject $InputObject @EnvPSBoundParameters |
| 229 | + } |
| 230 | + if ($null -eq $SapVirtualInstanceObj) { |
| 231 | + throw "$Name doesn't exist" |
| 232 | + } |
| 233 | + |
| 234 | + # If user input UserAssignedIdentity |
| 235 | + if ($PSBoundParameters.ContainsKey('UserAssignedIdentity')) { |
| 236 | + $userIdentityObject = [Microsoft.Azure.PowerShell.Cmdlets.Workloads.SapVirtualInstance.Models.UserAssignedIdentity]::New() |
| 237 | + $PSBoundParameters.IdentityUserAssignedIdentity = @{} |
| 238 | + foreach ($item in $PSBoundParameters.UserAssignedIdentity) { |
| 239 | + $PSBoundParameters.IdentityUserAssignedIdentity.Add($item, $userIdentityObject ) |
| 240 | + } |
| 241 | + |
| 242 | + if ($SapVirtualInstanceObj.IdentityUserAssignedIdentity.Count -gt 0) { |
| 243 | + $SapVirtualInstanceObj.IdentityUserAssignedIdentity.Keys | ForEach-Object { |
| 244 | + if (-NOT($_ -in $UserAssignedIdentity)) { |
| 245 | + $PSBoundParameters.IdentityUserAssignedIdentity.Add($_, $null) |
| 246 | + } |
| 247 | + } |
| 248 | + } |
| 249 | + } |
| 250 | + |
| 251 | + # calculate IdentityType |
| 252 | + $supportsSystemAssignedIdentity = $EnableSystemAssignedIdentity -or (($null -eq $EnableSystemAssignedIdentity) -and ($SapVirtualInstanceObj.IdentityType.Contains('SystemAssigned'))) |
| 253 | + $supportsUserAssignedIdentity = ($PSBoundParameters.ContainsKey('UserAssignedIdentity') -and $UserAssignedIdentity.Length -gt 0) -or ((-not $PSBoundParameters.ContainsKey('UserAssignedIdentity')) -and ($SapVirtualInstanceObj.IdentityType.Contains('UserAssigned'))); |
| 254 | + if (($supportsSystemAssignedIdentity -and $supportsUserAssignedIdentity)) { |
| 255 | + $PSBoundParameters.Add("IdentityType", "SystemAssigned,UserAssigned") |
| 256 | + } |
| 257 | + elseif ($supportsUserAssignedIdentity -and (-not $supportsSystemAssignedIdentity)) { |
| 258 | + $PSBoundParameters.Add("IdentityType", "UserAssigned") |
| 259 | + } |
| 260 | + elseif ((-not $supportsUserAssignedIdentity) -and $supportsSystemAssignedIdentity) { |
| 261 | + $PSBoundParameters.Add("IdentityType", "SystemAssigned") |
| 262 | + } |
| 263 | + else { |
| 264 | + $PSBoundParameters.Add("IdentityType", "None") |
| 265 | + } |
| 266 | + |
| 267 | + # remove EnableSystemAssignedIdentity |
| 268 | + if ($PSBoundParameters.ContainsKey('EnableSystemAssignedIdentity')) { |
| 269 | + $null = $PSBoundParameters.Remove("EnableSystemAssignedIdentity") |
| 270 | + } |
| 271 | + # remove UserAssignedIdentity |
| 272 | + if ($PSBoundParameters.ContainsKey('UserAssignedIdentity')) { |
| 273 | + $null = $PSBoundParameters.Remove('UserAssignedIdentity') |
| 274 | + } |
| 275 | + } |
| 276 | + Az.SapVirtualInstance.internal\Update-AzWorkloadsSapVirtualInstance @PSBoundParameters |
| 277 | + } |
| 278 | +} |
0 commit comments