|
| 1 | +# ---------------------------------------------------------------------------------- |
| 2 | +# |
| 3 | +# Copyright Microsoft Corporation |
| 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 | +# ---------------------------------------------------------------------------------- |
| 14 | + |
| 15 | +<# |
| 16 | +.Synopsis |
| 17 | +Creates an EventHub Namespace |
| 18 | +.Description |
| 19 | +Creates an EventHub Namespace |
| 20 | +#> |
| 21 | + |
| 22 | +function New-AzEventHubNamespaceV2{ |
| 23 | + [OutputType([Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.Api202201Preview.IEhNamespace])] |
| 24 | + [CmdletBinding(PositionalBinding = $false, SupportsShouldProcess, ConfirmImpact = 'Medium')] |
| 25 | + param( |
| 26 | + |
| 27 | + [Parameter(Mandatory, HelpMessage = "The name of EventHub namespace.")] |
| 28 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Path')] |
| 29 | + [System.String] |
| 30 | + # The name of EventHub namespace |
| 31 | + ${Name}, |
| 32 | + |
| 33 | + [Parameter(Mandatory, HelpMessage = "The name of the resource group. The name is case insensitive.")] |
| 34 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Path')] |
| 35 | + [System.String] |
| 36 | + # The name of the resource group. |
| 37 | + # The name is case insensitive. |
| 38 | + ${ResourceGroupName}, |
| 39 | + |
| 40 | + [Parameter(HelpMessage = "The ID of the target subscription.")] |
| 41 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Path')] |
| 42 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Runtime.DefaultInfo(Script = '(Get-AzContext).Subscription.Id')] |
| 43 | + [System.String] |
| 44 | + # The ID of the target subscription. |
| 45 | + ${SubscriptionId}, |
| 46 | + |
| 47 | + [Parameter(HelpMessage = "Alternate name specified when alias and namespace names are same")] |
| 48 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 49 | + [System.String] |
| 50 | + ${AlternateName}, |
| 51 | + |
| 52 | + [Parameter(HelpMessage = "Cluster ARM ID of the Namespace.")] |
| 53 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 54 | + [System.String] |
| 55 | + ${ClusterArmId}, |
| 56 | + |
| 57 | + [Parameter(HelpMessage = "This property disables SAS authentication for the Event Hubs namespace.")] |
| 58 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 59 | + [System.Management.Automation.SwitchParameter] |
| 60 | + ${DisableLocalAuth}, |
| 61 | + |
| 62 | + [Parameter(HelpMessage = "Enable Infrastructure Encryption (Double Encryption)")] |
| 63 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 64 | + [System.Management.Automation.SwitchParameter] |
| 65 | + ${RequireInfrastructureEncryption}, |
| 66 | + |
| 67 | + [Parameter(Mandatory, HelpMessage = "Cluster ARM ID of the Namespace.")] |
| 68 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 69 | + [System.String] |
| 70 | + ${Location}, |
| 71 | + |
| 72 | + [Parameter(HelpMessage = "Enabling this property creates a Standard Event Hubs Namespace in regions supported availability zones.")] |
| 73 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 74 | + [System.Management.Automation.SwitchParameter] |
| 75 | + ${ZoneRedundant}, |
| 76 | + |
| 77 | + [Parameter(HelpMessage = "Properties to configure Encryption")] |
| 78 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 79 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.Api202201Preview.IKeyVaultProperties[]] |
| 80 | + ${KeyVaultProperty}, |
| 81 | + |
| 82 | + [Parameter(HelpMessage = "Type of managed service identity.")] |
| 83 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 84 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Support.ManagedServiceIdentityType] |
| 85 | + ${IdentityType}, |
| 86 | + |
| 87 | + [Parameter(HelpMessage = "Properties for User Assigned Identities")] |
| 88 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 89 | + [System.String[]] |
| 90 | + # IdentityId |
| 91 | + ${UserAssignedIdentityId}, |
| 92 | + |
| 93 | + [Parameter(HelpMessage = "Value that indicates whether AutoInflate is enabled for eventhub namespace.")] |
| 94 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 95 | + [System.Management.Automation.SwitchParameter] |
| 96 | + ${EnableAutoInflate}, |
| 97 | + |
| 98 | + [Parameter(HelpMessage = "Upper limit of throughput units when AutoInflate is enabled, value should be within 0 to 20 throughput units. ( '0' if AutoInflateEnabled = true)")] |
| 99 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 100 | + [System.Int64] |
| 101 | + ${MaximumThroughputUnit}, |
| 102 | + |
| 103 | + [Parameter(HelpMessage = "The minimum TLS version for the cluster to support, e.g. '1.2'")] |
| 104 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 105 | + [System.String] |
| 106 | + ${MinimumTlsVersion}, |
| 107 | + |
| 108 | + [Parameter(HelpMessage = "The minimum TLS version for the cluster to support, e.g. '1.2'")] |
| 109 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 110 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Support.SkuName] |
| 111 | + ${SkuName}, |
| 112 | + |
| 113 | + [Parameter(HelpMessage = "This determines if traffic is allowed over public network. By default it is enabled.")] |
| 114 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 115 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Support.PublicNetworkAccess] |
| 116 | + ${PublicNetworkAccess}, |
| 117 | + |
| 118 | + [Parameter(HelpMessage = "The Event Hubs throughput units for Basic or Standard tiers, where value should be 0 to 20 throughput units. The Event Hubs premium units for Premium tier, where value should be 0 to 10 premium units.")] |
| 119 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 120 | + [System.Int64] |
| 121 | + ${SkuCapacity}, |
| 122 | + |
| 123 | + [Parameter(HelpMessage = "Tag of EventHub Namespace.")] |
| 124 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')] |
| 125 | + [System.Collections.Hashtable] |
| 126 | + ${Tag}, |
| 127 | + |
| 128 | + [Parameter(HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")] |
| 129 | + [Alias('AzureRMContext', 'AzureCredential')] |
| 130 | + [ValidateNotNull()] |
| 131 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Azure')] |
| 132 | + [System.Management.Automation.PSObject] |
| 133 | + ${DefaultProfile}, |
| 134 | + |
| 135 | + [Parameter(HelpMessage = "Run the command as a job")] |
| 136 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Runtime')] |
| 137 | + [System.Management.Automation.SwitchParameter] |
| 138 | + # Run the command as a job |
| 139 | + ${AsJob}, |
| 140 | + |
| 141 | + [Parameter(DontShow)] |
| 142 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Runtime')] |
| 143 | + [System.Management.Automation.SwitchParameter] |
| 144 | + # Wait for .NET debugger to attach |
| 145 | + ${Break}, |
| 146 | + |
| 147 | + [Parameter(DontShow)] |
| 148 | + [ValidateNotNull()] |
| 149 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Runtime')] |
| 150 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Runtime.SendAsyncStep[]] |
| 151 | + # SendAsync Pipeline Steps to be appended to the front of the pipeline |
| 152 | + ${HttpPipelineAppend}, |
| 153 | + |
| 154 | + [Parameter(DontShow)] |
| 155 | + [ValidateNotNull()] |
| 156 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Runtime')] |
| 157 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Runtime.SendAsyncStep[]] |
| 158 | + # SendAsync Pipeline Steps to be prepended to the front of the pipeline |
| 159 | + ${HttpPipelinePrepend}, |
| 160 | + |
| 161 | + [Parameter(DontShow)] |
| 162 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Runtime')] |
| 163 | + [System.Management.Automation.SwitchParameter] |
| 164 | + # Run the command asynchronously |
| 165 | + ${NoWait}, |
| 166 | + |
| 167 | + [Parameter(DontShow)] |
| 168 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Runtime')] |
| 169 | + [System.Uri] |
| 170 | + # The URI for the proxy server to use |
| 171 | + ${Proxy}, |
| 172 | + |
| 173 | + [Parameter(DontShow)] |
| 174 | + [ValidateNotNull()] |
| 175 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Runtime')] |
| 176 | + [System.Management.Automation.PSCredential] |
| 177 | + # Credentials for a proxy server to use for the remote call |
| 178 | + ${ProxyCredential}, |
| 179 | + |
| 180 | + [Parameter(DontShow)] |
| 181 | + [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Runtime')] |
| 182 | + [System.Management.Automation.SwitchParameter] |
| 183 | + # Use the default credentials for the proxy |
| 184 | + ${ProxyUseDefaultCredentials} |
| 185 | + ) |
| 186 | + process{ |
| 187 | + try{ |
| 188 | + $null = $PSBoundParameters.Remove('WhatIf') |
| 189 | + $null = $PSBoundParameters.Remove('Confirm') |
| 190 | + if($PSBoundParameters.ContainsKey('SkuName')){ |
| 191 | + $PSBoundParameters.Add('SkuTier', $SkuName) |
| 192 | + } |
| 193 | + |
| 194 | + if($PSBoundParameters.ContainsKey('KeyVaultProperty')){ |
| 195 | + $PSBoundParameters.Add('KeySource', 'Microsoft.KeyVault') |
| 196 | + } |
| 197 | + |
| 198 | + if($PSBoundParameters.ContainsKey('UserAssignedIdentityId')){ |
| 199 | + $identityHashTable = @{} |
| 200 | + |
| 201 | + foreach ($resourceID in $UserAssignedIdentityId){ |
| 202 | + $identityHashTable.Add($resourceID, [Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.Api202201Preview.UserAssignedIdentity]::new()) |
| 203 | + } |
| 204 | + |
| 205 | + $PSBoundParameters.Add("UserAssignedIdentity", $identityHashTable) |
| 206 | + $null = $PSBoundParameters.Remove("UserAssignedIdentityId") |
| 207 | + } |
| 208 | + if ($PSCmdlet.ShouldProcess("EventHub Namespace $($Name)", "Create or update")) { |
| 209 | + Az.EventHub.private\New-AzEventHubNamespaceV2_CreateExpanded @PSBoundParameters |
| 210 | + } |
| 211 | + } |
| 212 | + catch{ |
| 213 | + throw |
| 214 | + } |
| 215 | + } |
| 216 | +} |
0 commit comments