|
| 1 | + |
| 2 | +# ---------------------------------------------------------------------------------- |
| 3 | +# |
| 4 | +# Copyright Microsoft Corporation |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# ---------------------------------------------------------------------------------- |
| 15 | + |
| 16 | +<# |
| 17 | +.Synopsis |
| 18 | +Checks that the data connection parameters are valid. |
| 19 | +.Description |
| 20 | +Checks that the data connection parameters are valid. |
| 21 | +.Example |
| 22 | +PS C:\> $dataConnectionProperties = New-Object -Type Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200215.EventHubDataConnection -Property @{Location=$location; Kind=$kind; EventHubResourceId=$eventHubResourceId; DataFormat=$dataFormat; ConsumerGroup='$Default'; Compression= "None"; TableName = $tableName; MappingRuleName = $tableMappingName} |
| 23 | +PS C:\> $dataConnectionValidation = New-Object -Type Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200215.DataConnectionValidation -Property @{DataConnectionName=$dataConnectionName; Property=$dataConnectionProperties} |
| 24 | +PS C:\> Invoke-AzKustoDataConnectionValidation -ResourceGroupName $resourceGroupName -ClusterName $clusterName -DatabaseName $databaseName -Parameter $dataConnectionValidation |
| 25 | +
|
| 26 | +ErrorMessage |
| 27 | +------------ |
| 28 | +event hub resource id and consumer group tuple provided are already used |
| 29 | +
|
| 30 | +.Link |
| 31 | +https://docs.microsoft.com/en-us/powershell/module/az.kusto/invoke-azkustodataconnectionvalidation |
| 32 | +#> |
| 33 | +function Invoke-AzKustoDataConnectionValidation { |
| 34 | + [OutputType([Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200215.IDataConnectionValidationResult])] |
| 35 | + [CmdletBinding(DefaultParameterSetName = 'DataExpandedEventHub', PositionalBinding = $false, SupportsShouldProcess, ConfirmImpact = 'Medium')] |
| 36 | + param( |
| 37 | + [Parameter(ParameterSetName = 'DataExpandedEventHub', Mandatory)] |
| 38 | + [Parameter(ParameterSetName = 'DataExpandedEventGrid', Mandatory)] |
| 39 | + [Parameter(ParameterSetName = 'DataExpandedIotHub', Mandatory)] |
| 40 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Path')] |
| 41 | + [System.String] |
| 42 | + # The name of the Kusto cluster. |
| 43 | + ${ClusterName}, |
| 44 | + |
| 45 | + [Parameter(ParameterSetName = 'DataExpandedEventHub', Mandatory)] |
| 46 | + [Parameter(ParameterSetName = 'DataExpandedEventGrid', Mandatory)] |
| 47 | + [Parameter(ParameterSetName = 'DataExpandedIotHub', Mandatory)] |
| 48 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Path')] |
| 49 | + [System.String] |
| 50 | + # The name of the database in the Kusto cluster. |
| 51 | + ${DatabaseName}, |
| 52 | + |
| 53 | + [Parameter(ParameterSetName = 'DataExpandedEventHub', Mandatory)] |
| 54 | + [Parameter(ParameterSetName = 'DataExpandedEventGrid', Mandatory)] |
| 55 | + [Parameter(ParameterSetName = 'DataExpandedIotHub', Mandatory)] |
| 56 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Path')] |
| 57 | + [System.String] |
| 58 | + # The name of the resource group containing the Kusto cluster. |
| 59 | + ${ResourceGroupName}, |
| 60 | + |
| 61 | + [Parameter(ParameterSetName = 'DataExpandedEventHub')] |
| 62 | + [Parameter(ParameterSetName = 'DataExpandedEventGrid')] |
| 63 | + [Parameter(ParameterSetName = 'DataExpandedIotHub')] |
| 64 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Path')] |
| 65 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Runtime.DefaultInfo(Script = '(Get-AzContext).Subscription.Id')] |
| 66 | + [System.String] |
| 67 | + # Gets subscription credentials which uniquely identify Microsoft Azure subscription. |
| 68 | + # The subscription ID forms part of the URI for every service call. |
| 69 | + ${SubscriptionId}, |
| 70 | + |
| 71 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedEventHub', Mandatory, ValueFromPipeline)] |
| 72 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedEventGrid', Mandatory, ValueFromPipeline)] |
| 73 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedIotHub', Mandatory, ValueFromPipeline)] |
| 74 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Path')] |
| 75 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.IKustoIdentity] |
| 76 | + # Identity Parameter |
| 77 | + # To construct, see NOTES section for INPUTOBJECT properties and create a hash table. |
| 78 | + ${InputObject}, |
| 79 | + |
| 80 | + [Parameter(Mandatory)] |
| 81 | + [ArgumentCompleter( { param ( $CommandName, $ParameterName, $WordToComplete, $CommandAst, $FakeBoundParameters ) return @('EventHub', 'EventGrid', 'IoTHub') })] |
| 82 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 83 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Support.Kind] |
| 84 | + # Kind of the endpoint for the data connection |
| 85 | + ${Kind}, |
| 86 | + |
| 87 | + [Parameter(Mandatory)] |
| 88 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 89 | + [System.String] |
| 90 | + # The name of the data connection. |
| 91 | + ${DataConnectionName}, |
| 92 | + |
| 93 | + [Parameter(ParameterSetName = 'DataExpandedEventHub', Mandatory)] |
| 94 | + [Parameter(ParameterSetName = 'DataExpandedEventGrid', Mandatory)] |
| 95 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedEventHub', Mandatory)] |
| 96 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedEventGrid', Mandatory)] |
| 97 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 98 | + [System.String] |
| 99 | + # The resource ID of the event hub to be used to create a data connection / event grid is configured to send events. |
| 100 | + ${EventHubResourceId}, |
| 101 | + |
| 102 | + [Parameter(Mandatory)] |
| 103 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 104 | + [System.String] |
| 105 | + # The event/iot hub consumer group. |
| 106 | + ${ConsumerGroup}, |
| 107 | + |
| 108 | + [Parameter(ParameterSetName = 'DataExpandedEventHub')] |
| 109 | + [Parameter(ParameterSetName = 'DataExpandedEventGrid', Mandatory)] |
| 110 | + [Parameter(ParameterSetName = 'DataExpandedIotHub')] |
| 111 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedEventHub')] |
| 112 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedEventGrid', Mandatory)] |
| 113 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedIotHub')] |
| 114 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 115 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Support.EventGridDataFormat] |
| 116 | + # The data format of the message. Optionally the data format can be added to each message. |
| 117 | + ${DataFormat}, |
| 118 | + |
| 119 | + [Parameter(ParameterSetName = 'DataExpandedEventHub')] |
| 120 | + [Parameter(ParameterSetName = 'DataExpandedIotHub')] |
| 121 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedEventHub')] |
| 122 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedIotHub')] |
| 123 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 124 | + [System.String[]] |
| 125 | + # System properties of the event/iot hub. |
| 126 | + ${EventSystemProperty}, |
| 127 | + |
| 128 | + [Parameter()] |
| 129 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 130 | + [System.String] |
| 131 | + # The mapping rule to be used to ingest the data. Optionally the mapping information can be added to each message. |
| 132 | + ${MappingRuleName}, |
| 133 | + |
| 134 | + [Parameter(ParameterSetName = 'DataExpandedEventHub')] |
| 135 | + [Parameter(ParameterSetName = 'DataExpandedEventGrid', Mandatory)] |
| 136 | + [Parameter(ParameterSetName = 'DataExpandedIotHub')] |
| 137 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedEventHub')] |
| 138 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedEventGrid', Mandatory)] |
| 139 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedIotHub')] |
| 140 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 141 | + [System.String] |
| 142 | + # The table where the data should be ingested. Optionally the table information can be added to each message. |
| 143 | + ${TableName}, |
| 144 | + |
| 145 | + [Parameter(ParameterSetName = 'DataExpandedEventHub')] |
| 146 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedEventHub')] |
| 147 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 148 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Support.Compression] |
| 149 | + # The event hub messages compression type. |
| 150 | + ${Compression}, |
| 151 | + |
| 152 | + [Parameter(ParameterSetName = 'DataExpandedEventGrid', Mandatory)] |
| 153 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedEventGrid', Mandatory)] |
| 154 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 155 | + [System.String] |
| 156 | + # The resource ID of the storage account where the data resides. |
| 157 | + ${StorageAccountResourceId}, |
| 158 | + |
| 159 | + [Parameter(ParameterSetName = 'DataExpandedIotHub', Mandatory)] |
| 160 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedIotHub', Mandatory)] |
| 161 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 162 | + [System.String] |
| 163 | + # The resource ID of the Iot hub to be used to create a data connection. |
| 164 | + ${IotHubResourceId}, |
| 165 | + |
| 166 | + [Parameter(ParameterSetName = 'DataExpandedIotHub', Mandatory)] |
| 167 | + [Parameter(ParameterSetName = 'DataViaIdentityExpandedIotHub', Mandatory)] |
| 168 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 169 | + [System.String] |
| 170 | + # The name of the share access policy. |
| 171 | + ${SharedAccessPolicyName}, |
| 172 | + |
| 173 | + [Parameter(Mandatory)] |
| 174 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Body')] |
| 175 | + [System.String] |
| 176 | + # Resource location. |
| 177 | + ${Location}, |
| 178 | + |
| 179 | + [Parameter()] |
| 180 | + [Alias('AzureRMContext', 'AzureCredential')] |
| 181 | + [ValidateNotNull()] |
| 182 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Azure')] |
| 183 | + [System.Management.Automation.PSObject] |
| 184 | + # The credentials, account, tenant, and subscription used for communication with Azure. |
| 185 | + ${DefaultProfile}, |
| 186 | + |
| 187 | + [Parameter(DontShow)] |
| 188 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Runtime')] |
| 189 | + [System.Management.Automation.SwitchParameter] |
| 190 | + # Wait for .NET debugger to attach |
| 191 | + ${Break}, |
| 192 | + |
| 193 | + [Parameter(DontShow)] |
| 194 | + [ValidateNotNull()] |
| 195 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Runtime')] |
| 196 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Runtime.SendAsyncStep[]] |
| 197 | + # SendAsync Pipeline Steps to be appended to the front of the pipeline |
| 198 | + ${HttpPipelineAppend}, |
| 199 | + |
| 200 | + [Parameter(DontShow)] |
| 201 | + [ValidateNotNull()] |
| 202 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Runtime')] |
| 203 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Runtime.SendAsyncStep[]] |
| 204 | + # SendAsync Pipeline Steps to be prepended to the front of the pipeline |
| 205 | + ${HttpPipelinePrepend}, |
| 206 | + |
| 207 | + [Parameter(DontShow)] |
| 208 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Runtime')] |
| 209 | + [System.Uri] |
| 210 | + # The URI for the proxy server to use |
| 211 | + ${Proxy}, |
| 212 | + |
| 213 | + [Parameter(DontShow)] |
| 214 | + [ValidateNotNull()] |
| 215 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Runtime')] |
| 216 | + [System.Management.Automation.PSCredential] |
| 217 | + # Credentials for a proxy server to use for the remote call |
| 218 | + ${ProxyCredential}, |
| 219 | + |
| 220 | + [Parameter(DontShow)] |
| 221 | + [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Category('Runtime')] |
| 222 | + [System.Management.Automation.SwitchParameter] |
| 223 | + # Use the default credentials for the proxy |
| 224 | + ${ProxyUseDefaultCredentials} |
| 225 | + ) |
| 226 | + |
| 227 | + process { |
| 228 | + try { |
| 229 | + $Parameter = [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200215.DataConnectionValidation]::new() |
| 230 | + |
| 231 | + $Parameter.DataConnectionName = $PSBoundParameters['DataConnectionName'] |
| 232 | + $null = $PSBoundParameters.Remove('DataConnectionName') |
| 233 | + |
| 234 | + if ($PSBoundParameters['Kind'] -eq 'EventHub') { |
| 235 | + $Parameter.Property = [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200215.EventHubDataConnection]::new() |
| 236 | + |
| 237 | + $Parameter.Property.EventHubResourceId = $PSBoundParameters['EventHubResourceId'] |
| 238 | + $null = $PSBoundParameters.Remove('EventHubResourceId') |
| 239 | + |
| 240 | + if ($PSBoundParameters.ContainsKey('EventSystemProperty')) { |
| 241 | + $Parameter.Property.EventSystemProperty = $PSBoundParameters['EventSystemProperty'] |
| 242 | + $null = $PSBoundParameters.Remove('EventSystemProperty') |
| 243 | + } |
| 244 | + |
| 245 | + if ($PSBoundParameters.ContainsKey('Compression')) { |
| 246 | + $Parameter.Property.Compression = $PSBoundParameters['Compression'] |
| 247 | + $null = $PSBoundParameters.Remove('Compression') |
| 248 | + } |
| 249 | + } |
| 250 | + elseif ($PSBoundParameters['Kind'] -eq 'EventGrid') { |
| 251 | + $Parameter.Property = [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200215.EventGridDataConnection]::new() |
| 252 | + |
| 253 | + $Parameter.Property.EventHubResourceId = $PSBoundParameters['EventHubResourceId'] |
| 254 | + $null = $PSBoundParameters.Remove('EventHubResourceId') |
| 255 | + |
| 256 | + $Parameter.Property.StorageAccountResourceId = $PSBoundParameters['StorageAccountResourceId'] |
| 257 | + $null = $PSBoundParameters.Remove('StorageAccountResourceId') |
| 258 | + } |
| 259 | + else { |
| 260 | + $Parameter.Property = [Microsoft.Azure.PowerShell.Cmdlets.Kusto.Models.Api20200215.IotHubDataConnection]::new() |
| 261 | + |
| 262 | + $Parameter.Property.IotHubResourceId = $PSBoundParameters['IotHubResourceId'] |
| 263 | + $null = $PSBoundParameters.Remove('IotHubResourceId') |
| 264 | + |
| 265 | + $Parameter.Property.SharedAccessPolicyName = $PSBoundParameters['SharedAccessPolicyName'] |
| 266 | + $null = $PSBoundParameters.Remove('SharedAccessPolicyName') |
| 267 | + |
| 268 | + if ($PSBoundParameters.ContainsKey('EventSystemProperty')) { |
| 269 | + $Parameter.Property.EventSystemProperty = $PSBoundParameters['EventSystemProperty'] |
| 270 | + $null = $PSBoundParameters.Remove('EventSystemProperty') |
| 271 | + } |
| 272 | + } |
| 273 | + |
| 274 | + $Parameter.Property.Kind = $PSBoundParameters['Kind'] |
| 275 | + $null = $PSBoundParameters.Remove('Kind') |
| 276 | + |
| 277 | + $Parameter.Property.Location = $PSBoundParameters['Location'] |
| 278 | + $null = $PSBoundParameters.Remove('Location') |
| 279 | + |
| 280 | + $Parameter.Property.ConsumerGroup = $PSBoundParameters['ConsumerGroup'] |
| 281 | + $null = $PSBoundParameters.Remove('ConsumerGroup') |
| 282 | + |
| 283 | + if ($PSBoundParameters.ContainsKey('DataFormat')) { |
| 284 | + $Parameter.Property.DataFormat = $PSBoundParameters['DataFormat'] |
| 285 | + $null = $PSBoundParameters.Remove('DataFormat') |
| 286 | + } |
| 287 | + |
| 288 | + if ($PSBoundParameters.ContainsKey('MappingRuleName')) { |
| 289 | + $Parameter.Property.MappingRuleName = $PSBoundParameters['MappingRuleName'] |
| 290 | + $null = $PSBoundParameters.Remove('MappingRuleName') |
| 291 | + } |
| 292 | + |
| 293 | + if ($PSBoundParameters.ContainsKey('TableName')) { |
| 294 | + $Parameter.Property.TableName = $PSBoundParameters['TableName'] |
| 295 | + $null = $PSBoundParameters.Remove('TableName') |
| 296 | + } |
| 297 | + |
| 298 | + $null = $PSBoundParameters.Add('Parameter', $Parameter) |
| 299 | + |
| 300 | + Az.Kusto.internal\Invoke-AzKustoDataConnectionValidation @PSBoundParameters |
| 301 | + } |
| 302 | + catch { |
| 303 | + throw |
| 304 | + } |
| 305 | + } |
| 306 | +} |
0 commit comments