|
| 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 | +Asynchronously create a new storage task assignment sub-resource with the specified parameters. |
| 20 | +If a storage task assignment is already created and a subsequent create request is issued with different properties, the storage task assignment properties will be updated. |
| 21 | +If a storage task assignment is already created and a subsequent create request is issued with the exact same set of properties, the request will succeed. |
| 22 | +.Description |
| 23 | +Asynchronously create a new storage task assignment sub-resource with the specified parameters. |
| 24 | +If a storage task assignment is already created and a subsequent create request is issued with different properties, the storage task assignment properties will be updated. |
| 25 | +If a storage task assignment is already created and a subsequent create request is issued with the exact same set of properties, the request will succeed. |
| 26 | +.Example |
| 27 | +$taskid = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.StorageActions/storageTasks/mytask" |
| 28 | +New-AzStorageTaskAssignment -ResourceGroupName myresourcegroup -AccountName myaccount -name mytaskassignment -TaskId $taskid -ReportPrefix "test" -TriggerType RunOnce -StartOn (Get-Date).ToUniversalTime() -Description "task assignment" -Enabled:$false |
| 29 | +.Example |
| 30 | +$start = Get-Date -Year 2024 -Month 8 -Day 7 -Hour 1 -Minute 30 |
| 31 | +$end = Get-Date -Year 2024 -Month 12 -Day 25 -Hour 2 -Minute 45 |
| 32 | +$taskid = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myresourcegroup/providers/Microsoft.StorageActions/storageTasks/mytask" |
| 33 | +New-AzStorageTaskAssignment -accountname myaccount -name mytaskassignment -resourcegroupname myresourcegroup -TaskId $taskid -ReportPrefix test -StartFrom $start.ToUniversalTime() -TriggerType OnSchedule -Interval 10 -IntervalUnit Days -Description "my task assignment" -Enabled:$false -EndBy $end.ToUniversalTime() |
| 34 | +
|
| 35 | +.Outputs |
| 36 | +Microsoft.Azure.PowerShell.Cmdlets.Storage.Models.IStorageTaskAssignment |
| 37 | +.Link |
| 38 | +https://learn.microsoft.com/powershell/module/az.storage/new-azstoragetaskassignment |
| 39 | +#> |
| 40 | +function New-AzStorageTaskAssignment { |
| 41 | +[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Storage.Models.IStorageTaskAssignment])] |
| 42 | +[CmdletBinding(DefaultParameterSetName='CreateExpanded', PositionalBinding=$false, SupportsShouldProcess, ConfirmImpact='Medium')] |
| 43 | +param( |
| 44 | + [Parameter(Mandatory)] |
| 45 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Path')] |
| 46 | + [System.String] |
| 47 | + # The name of the storage account within the specified resource group. |
| 48 | + # Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only. |
| 49 | + ${AccountName}, |
| 50 | + |
| 51 | + [Parameter(Mandatory)] |
| 52 | + [Alias('StorageTaskAssignmentName')] |
| 53 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Path')] |
| 54 | + [System.String] |
| 55 | + # The name of the storage task assignment within the specified resource group. |
| 56 | + # Storage task assignment names must be between 3 and 24 characters in length and use numbers and lower-case letters only. |
| 57 | + ${Name}, |
| 58 | + |
| 59 | + [Parameter(Mandatory)] |
| 60 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Path')] |
| 61 | + [System.String] |
| 62 | + # The name of the resource group. |
| 63 | + # The name is case insensitive. |
| 64 | + ${ResourceGroupName}, |
| 65 | + |
| 66 | + [Parameter()] |
| 67 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Path')] |
| 68 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] |
| 69 | + [System.String] |
| 70 | + # The ID of the target subscription. |
| 71 | + ${SubscriptionId}, |
| 72 | + |
| 73 | + [Parameter(Mandatory)] |
| 74 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Body')] |
| 75 | + [System.String] |
| 76 | + # Text that describes the purpose of the storage task assignment |
| 77 | + ${Description}, |
| 78 | + |
| 79 | + [Parameter(Mandatory)] |
| 80 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Body')] |
| 81 | + [System.Management.Automation.SwitchParameter] |
| 82 | + # Whether the storage task assignment is enabled or not |
| 83 | + ${Enabled}, |
| 84 | + |
| 85 | + [Parameter(Mandatory)] |
| 86 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Body')] |
| 87 | + [System.String] |
| 88 | + # The container prefix for the location of storage task assignment report |
| 89 | + ${ReportPrefix}, |
| 90 | + |
| 91 | + [Parameter(Mandatory)] |
| 92 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Body')] |
| 93 | + [System.String] |
| 94 | + # Id of the corresponding storage task |
| 95 | + ${TaskId}, |
| 96 | + |
| 97 | + [Parameter(Mandatory)] |
| 98 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.PSArgumentCompleterAttribute("RunOnce", "OnSchedule")] |
| 99 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Body')] |
| 100 | + [System.String] |
| 101 | + # The trigger type of the storage task assignment execution |
| 102 | + ${TriggerType}, |
| 103 | + |
| 104 | + [Parameter()] |
| 105 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Body')] |
| 106 | + [System.DateTime] |
| 107 | + # When to end task execution. |
| 108 | + # This is a required field when ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce' |
| 109 | + ${EndBy}, |
| 110 | + |
| 111 | + [Parameter()] |
| 112 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Body')] |
| 113 | + [System.Int32] |
| 114 | + # Run interval of task execution. |
| 115 | + # This is a required field when ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce' |
| 116 | + ${Interval}, |
| 117 | + |
| 118 | + [Parameter()] |
| 119 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.PSArgumentCompleterAttribute("Days")] |
| 120 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Body')] |
| 121 | + [System.String] |
| 122 | + # Run interval unit of task execution. |
| 123 | + # This is a required field when ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce' |
| 124 | + ${IntervalUnit}, |
| 125 | + |
| 126 | + [Parameter()] |
| 127 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Body')] |
| 128 | + [System.DateTime] |
| 129 | + # When to start task execution. |
| 130 | + # This is a required field when ExecutionTrigger.properties.type is 'OnSchedule'; this property should not be present when ExecutionTrigger.properties.type is 'RunOnce' |
| 131 | + ${StartFrom}, |
| 132 | + |
| 133 | + [Parameter()] |
| 134 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Body')] |
| 135 | + [System.DateTime] |
| 136 | + # When to start task execution. |
| 137 | + # This is a required field when ExecutionTrigger.properties.type is 'RunOnce'; this property should not be present when ExecutionTrigger.properties.type is 'OnSchedule' |
| 138 | + ${StartOn}, |
| 139 | + |
| 140 | + [Parameter()] |
| 141 | + [AllowEmptyCollection()] |
| 142 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Body')] |
| 143 | + [System.String[]] |
| 144 | + # List of object prefixes to be excluded from task execution. |
| 145 | + # If there is a conflict between include and exclude prefixes, the exclude prefix will be the determining factor |
| 146 | + ${TargetExcludePrefix}, |
| 147 | + |
| 148 | + [Parameter()] |
| 149 | + [AllowEmptyCollection()] |
| 150 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Body')] |
| 151 | + [System.String[]] |
| 152 | + # Required list of object prefixes to be included for task execution |
| 153 | + ${TargetPrefix}, |
| 154 | + |
| 155 | + [Parameter()] |
| 156 | + [Alias('AzureRMContext', 'AzureCredential')] |
| 157 | + [ValidateNotNull()] |
| 158 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Azure')] |
| 159 | + [System.Management.Automation.PSObject] |
| 160 | + # The DefaultProfile parameter is not functional. |
| 161 | + # Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription. |
| 162 | + ${DefaultProfile}, |
| 163 | + |
| 164 | + [Parameter()] |
| 165 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Runtime')] |
| 166 | + [System.Management.Automation.SwitchParameter] |
| 167 | + # Run the command as a job |
| 168 | + ${AsJob}, |
| 169 | + |
| 170 | + [Parameter(DontShow)] |
| 171 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Runtime')] |
| 172 | + [System.Management.Automation.SwitchParameter] |
| 173 | + # Wait for .NET debugger to attach |
| 174 | + ${Break}, |
| 175 | + |
| 176 | + [Parameter(DontShow)] |
| 177 | + [ValidateNotNull()] |
| 178 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Runtime')] |
| 179 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.SendAsyncStep[]] |
| 180 | + # SendAsync Pipeline Steps to be appended to the front of the pipeline |
| 181 | + ${HttpPipelineAppend}, |
| 182 | + |
| 183 | + [Parameter(DontShow)] |
| 184 | + [ValidateNotNull()] |
| 185 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Runtime')] |
| 186 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.SendAsyncStep[]] |
| 187 | + # SendAsync Pipeline Steps to be prepended to the front of the pipeline |
| 188 | + ${HttpPipelinePrepend}, |
| 189 | + |
| 190 | + [Parameter()] |
| 191 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Runtime')] |
| 192 | + [System.Management.Automation.SwitchParameter] |
| 193 | + # Run the command asynchronously |
| 194 | + ${NoWait}, |
| 195 | + |
| 196 | + [Parameter(DontShow)] |
| 197 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Runtime')] |
| 198 | + [System.Uri] |
| 199 | + # The URI for the proxy server to use |
| 200 | + ${Proxy}, |
| 201 | + |
| 202 | + [Parameter(DontShow)] |
| 203 | + [ValidateNotNull()] |
| 204 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Runtime')] |
| 205 | + [System.Management.Automation.PSCredential] |
| 206 | + # Credentials for a proxy server to use for the remote call |
| 207 | + ${ProxyCredential}, |
| 208 | + |
| 209 | + [Parameter(DontShow)] |
| 210 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Category('Runtime')] |
| 211 | + [System.Management.Automation.SwitchParameter] |
| 212 | + # Use the default credentials for the proxy |
| 213 | + ${ProxyUseDefaultCredentials} |
| 214 | +) |
| 215 | + |
| 216 | +begin { |
| 217 | + try { |
| 218 | + $outBuffer = $null |
| 219 | + if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer)) { |
| 220 | + $PSBoundParameters['OutBuffer'] = 1 |
| 221 | + } |
| 222 | + $parameterSet = $PSCmdlet.ParameterSetName |
| 223 | + |
| 224 | + $testPlayback = $false |
| 225 | + $PSBoundParameters['HttpPipelinePrepend'] | Foreach-Object { if ($_) { $testPlayback = $testPlayback -or ('Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.PipelineMock' -eq $_.Target.GetType().FullName -and 'Playback' -eq $_.Target.Mode) } } |
| 226 | + |
| 227 | + $context = Get-AzContext |
| 228 | + if (-not $context -and -not $testPlayback) { |
| 229 | + Write-Error "No Azure login detected. Please run 'Connect-AzAccount' to log in." |
| 230 | + exit |
| 231 | + } |
| 232 | + |
| 233 | + if ($null -eq [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion) { |
| 234 | + [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PowerShellVersion = $PSVersionTable.PSVersion.ToString() |
| 235 | + } |
| 236 | + $preTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId |
| 237 | + if ($preTelemetryId -eq '') { |
| 238 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId =(New-Guid).ToString() |
| 239 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.module]::Instance.Telemetry.Invoke('Create', $MyInvocation, $parameterSet, $PSCmdlet) |
| 240 | + } else { |
| 241 | + $internalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets |
| 242 | + if ($internalCalledCmdlets -eq '') { |
| 243 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $MyInvocation.MyCommand.Name |
| 244 | + } else { |
| 245 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets += ',' + $MyInvocation.MyCommand.Name |
| 246 | + } |
| 247 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = 'internal' |
| 248 | + } |
| 249 | + |
| 250 | + $mapping = @{ |
| 251 | + CreateExpanded = 'Az.Storage.private\New-AzStorageTaskAssignment_CreateExpanded'; |
| 252 | + } |
| 253 | + if (('CreateExpanded') -contains $parameterSet -and -not $PSBoundParameters.ContainsKey('SubscriptionId') ) { |
| 254 | + if ($testPlayback) { |
| 255 | + $PSBoundParameters['SubscriptionId'] = . (Join-Path $PSScriptRoot '..' 'utils' 'Get-SubscriptionIdTestSafe.ps1') |
| 256 | + } else { |
| 257 | + $PSBoundParameters['SubscriptionId'] = (Get-AzContext).Subscription.Id |
| 258 | + } |
| 259 | + } |
| 260 | + $cmdInfo = Get-Command -Name $mapping[$parameterSet] |
| 261 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.MessageAttributeHelper]::ProcessCustomAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet) |
| 262 | + if ($null -ne $MyInvocation.MyCommand -and [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets -notcontains $MyInvocation.MyCommand.Name -and [Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.MessageAttributeHelper]::ContainsPreviewAttribute($cmdInfo, $MyInvocation)){ |
| 263 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.Runtime.MessageAttributeHelper]::ProcessPreviewMessageAttributesAtRuntime($cmdInfo, $MyInvocation, $parameterSet, $PSCmdlet) |
| 264 | + [Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet]::PromptedPreviewMessageCmdlets.Enqueue($MyInvocation.MyCommand.Name) |
| 265 | + } |
| 266 | + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Cmdlet) |
| 267 | + if ($wrappedCmd -eq $null) { |
| 268 | + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand(($mapping[$parameterSet]), [System.Management.Automation.CommandTypes]::Function) |
| 269 | + } |
| 270 | + $scriptCmd = {& $wrappedCmd @PSBoundParameters} |
| 271 | + $steppablePipeline = $scriptCmd.GetSteppablePipeline($MyInvocation.CommandOrigin) |
| 272 | + $steppablePipeline.Begin($PSCmdlet) |
| 273 | + } catch { |
| 274 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 275 | + throw |
| 276 | + } |
| 277 | +} |
| 278 | + |
| 279 | +process { |
| 280 | + try { |
| 281 | + $steppablePipeline.Process($_) |
| 282 | + } catch { |
| 283 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 284 | + throw |
| 285 | + } |
| 286 | + |
| 287 | + finally { |
| 288 | + $backupTelemetryId = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId |
| 289 | + $backupInternalCalledCmdlets = [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets |
| 290 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 291 | + } |
| 292 | + |
| 293 | +} |
| 294 | +end { |
| 295 | + try { |
| 296 | + $steppablePipeline.End() |
| 297 | + |
| 298 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $backupTelemetryId |
| 299 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::InternalCalledCmdlets = $backupInternalCalledCmdlets |
| 300 | + if ($preTelemetryId -eq '') { |
| 301 | + [Microsoft.Azure.PowerShell.Cmdlets.Storage.module]::Instance.Telemetry.Invoke('Send', $MyInvocation, $parameterSet, $PSCmdlet) |
| 302 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 303 | + } |
| 304 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::TelemetryId = $preTelemetryId |
| 305 | + |
| 306 | + } catch { |
| 307 | + [Microsoft.WindowsAzure.Commands.Common.MetricHelper]::ClearTelemetryContext() |
| 308 | + throw |
| 309 | + } |
| 310 | +} |
| 311 | +} |
0 commit comments