Skip to content

EventHub Failover cmdlets #27693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/EventHub/EventHub.Autorest/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ tools
test/*-TestResults.xml
license.txt
/*.ps1
/*.psd1
/*.ps1xml
/*.psm1
/*.snk
Expand Down
24 changes: 24 additions & 0 deletions src/EventHub/EventHub.Autorest/Az.EventHub.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@{
GUID = '9e121baf-ee5e-4cb7-bb95-fff6bb4ee003'
RootModule = './Az.EventHub.psm1'
ModuleVersion = '0.1.0'
CompatiblePSEditions = 'Core', 'Desktop'
Author = 'Microsoft Corporation'
CompanyName = 'Microsoft Corporation'
Copyright = 'Microsoft Corporation. All rights reserved.'
Description = 'Microsoft Azure PowerShell: EventHub cmdlets'
PowerShellVersion = '5.1'
DotNetFrameworkVersion = '4.7.2'
RequiredAssemblies = './bin/Az.EventHub.private.dll'
FormatsToProcess = './Az.EventHub.format.ps1xml'
FunctionsToExport = 'Approve-AzEventHubPrivateEndpointConnection', 'Deny-AzEventHubPrivateEndpointConnection', 'Get-AzEventHub', 'Get-AzEventHubApplicationGroup', 'Get-AzEventHubAuthorizationRule', 'Get-AzEventHubCluster', 'Get-AzEventHubClusterNamespace', 'Get-AzEventHubClustersAvailableRegion', 'Get-AzEventHubConsumerGroup', 'Get-AzEventHubGeoDRConfiguration', 'Get-AzEventHubKey', 'Get-AzEventHubNamespace', 'Get-AzEventHubNetworkRuleSet', 'Get-AzEventHubPrivateEndpointConnection', 'Get-AzEventHubPrivateLink', 'Get-AzEventHubSchemaGroup', 'New-AzEventHub', 'New-AzEventHubApplicationGroup', 'New-AzEventHubAuthorizationRule', 'New-AzEventHubCluster', 'New-AzEventHubConsumerGroup', 'New-AzEventHubGeoDRConfiguration', 'New-AzEventHubIPRuleConfig', 'New-AzEventHubKey', 'New-AzEventHubKeyVaultPropertiesObject', 'New-AzEventHubLocationsNameObject', 'New-AzEventHubNamespace', 'New-AzEventHubSchemaGroup', 'New-AzEventHubThrottlingPolicyConfig', 'New-AzEventHubVirtualNetworkRuleConfig', 'Remove-AzEventHub', 'Remove-AzEventHubApplicationGroup', 'Remove-AzEventHubAuthorizationRule', 'Remove-AzEventHubCluster', 'Remove-AzEventHubConsumerGroup', 'Remove-AzEventHubGeoDRConfiguration', 'Remove-AzEventHubNamespace', 'Remove-AzEventHubPrivateEndpointConnection', 'Remove-AzEventHubSchemaGroup', 'Set-AzEventHub', 'Set-AzEventHubApplicationGroup', 'Set-AzEventHubAuthorizationRule', 'Set-AzEventHubCluster', 'Set-AzEventHubConsumerGroup', 'Set-AzEventHubGeoDRConfigurationBreakPair', 'Set-AzEventHubGeoDRConfigurationFailOver', 'Set-AzEventHubNamespace', 'Set-AzEventHubNetworkRuleSet', 'Start-AzEventHubNamespaceFailOver', 'Test-AzEventHubName'
AliasesToExport = 'Get-AzEventHubNamespaceV2', 'New-AzEventHubNamespaceV2', 'Remove-AzEventHubNamespaceV2', 'Set-AzEventHubNamespaceV2'
PrivateData = @{
PSData = @{
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'EventHub'
LicenseUri = 'https://aka.ms/azps-license'
ProjectUri = 'https://github.com/Azure/azure-powershell'
ReleaseNotes = ''
}
}
}
26 changes: 26 additions & 0 deletions src/EventHub/EventHub.Autorest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the ""License"");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an ""AS IS"" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
// is regenerated.

using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: System.Reflection.AssemblyCompanyAttribute("Microsoft")]
[assembly: System.Reflection.AssemblyCopyrightAttribute("Copyright © Microsoft")]
[assembly: System.Reflection.AssemblyProductAttribute("Microsoft Azure PowerShell")]
[assembly: System.Reflection.AssemblyTitleAttribute("Microsoft Azure PowerShell - EventHub")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("0.1.0.0")]
[assembly: System.Reflection.AssemblyVersionAttribute("0.1.0.0")]
[assembly: System.Runtime.InteropServices.ComVisibleAttribute(false)]
[assembly: System.CLSCompliantAttribute(false)]
30 changes: 17 additions & 13 deletions src/EventHub/EventHub.Autorest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ For information on how to develop for `Az.EventHub`, see [how-to.md](how-to.md).

``` yaml
# Please specify the commit id that includes your features to make sure generated codes stable.
commit: bb87821da87100719c7dc8a3ef6b89781813ed0a
commit: 91288ed6ade4e8cef4b052891b51bbdbf69090fb
require:
# readme.azure.noprofile.md is the common configuration file
- $(this-folder)/../../readme.azure.noprofile.md
input-file:
# You need to specify your swagger files here.
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2023-01-01-preview/AvailableClusterRegions-preview.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2023-01-01-preview/Clusters-preview.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2023-01-01-preview/namespaces-preview.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2023-01-01-preview/networkrulessets-preview.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2023-01-01-preview/AuthorizationRules.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2023-01-01-preview/CheckNameAvailability.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2023-01-01-preview/consumergroups.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2023-01-01-preview/disasterRecoveryConfigs.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2023-01-01-preview/operations.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2023-01-01-preview/SchemaRegistry.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2024-05-01-preview/AvailableClusterRegions-preview.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2024-05-01-preview/Clusters-preview.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2024-05-01-preview/namespaces.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2024-05-01-preview/networkrulessets-preview.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2024-05-01-preview/AuthorizationRules.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2024-05-01-preview/CheckNameAvailability.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2024-05-01-preview/consumergroups.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2024-05-01-preview/disasterRecoveryConfigs.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2024-05-01-preview/operations.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2024-05-01-preview/SchemaRegistry.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2024-05-01-preview/eventhubs.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2023-01-01-preview/ApplicationGroups.json
- $(repo)/specification/eventhub/resource-manager/Microsoft.EventHub/preview/2024-05-01-preview/ApplicationGroups.json
# If the swagger has not been put in the repo, you may uncomment the following line and refer to it locally
# - (this-folder)/relative-path-to-your-swagger

Expand Down Expand Up @@ -75,7 +75,7 @@ directive:
remove: true
- where:
verb: Set
remove: true
hide: true
- where:
verb: Update
remove: true
Expand Down Expand Up @@ -481,4 +481,8 @@ directive:
- model-cmdlet:
- model-name: KeyVaultProperties
cmdlet-name: New-AzEventHubKeyVaultPropertiesObject

- model-cmdlet:
- model-name: NamespaceReplicaLocation
cmdlet-name: New-AzEventHubLocationsNameObject
```
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "clusters",
"apiVersion": "2023-01-01-preview",
"apiVersion": "2024-05-01-preview",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.eventhub"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "namespaces/applicationGroups",
"apiVersion": "2023-01-01-preview",
"apiVersion": "2024-05-01-preview",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.eventhub"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "namespaces/disasterRecoveryConfigs",
"apiVersion": "2023-01-01-preview",
"apiVersion": "2024-05-01-preview",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.eventhub"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "namespaces/eventhubs/consumergroups",
"apiVersion": "2023-01-01-preview",
"apiVersion": "2024-05-01-preview",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.eventhub"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "namespaces/privateEndpointConnections",
"apiVersion": "2023-01-01-preview",
"apiVersion": "2024-05-01-preview",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.eventhub"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "namespaces/schemagroups",
"apiVersion": "2023-01-01-preview",
"apiVersion": "2024-05-01-preview",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.eventhub"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"resourceType": "namespaces",
"apiVersion": "2023-01-01-preview",
"apiVersion": "2024-05-01-preview",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/az.eventhub"
},
Expand Down
4 changes: 2 additions & 2 deletions src/EventHub/EventHub.Autorest/custom/Az.EventHub.custom.psm1
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# region Generated
# Load the private module dll
$null = Import-Module -PassThru -Name (Join-Path $PSScriptRoot '..\bin\Az.EventHub.private.dll')
$null = Import-Module -PassThru -Name (Join-Path $PSScriptRoot '../bin/Az.EventHub.private.dll')

# Load the internal module
$internalModulePath = Join-Path $PSScriptRoot '..\internal\Az.EventHub.internal.psm1'
$internalModulePath = Join-Path $PSScriptRoot '../internal/Az.EventHub.internal.psm1'
if(Test-Path $internalModulePath) {
$null = Import-Module -Name $internalModulePath
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,15 @@ function New-AzEventHubNamespace{
[System.Collections.Hashtable]
${Tag},

[Parameter(HelpMessage = "The maximum acceptable lag for data replication operations from the primary replica to a quorum of secondary replicas. When the lag exceeds the configured amount, operations on the primary replica will be failed. The allowed values are 0 and 5 minutes to 1 day.")]
[Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')]
[System.Int64]
${GeoDataReplicationMaxReplicationLagDurationInSecond},

[Parameter(HelpMessage = "Properties for User Assigned Identities")]
[Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.INamespaceReplicaLocation[]]
${GeoDataReplicationLocation},

[Parameter(HelpMessage = "The credentials, account, tenant, and subscription used for communication with Azure.")]
[Alias('AzureRMContext', 'AzureCredential')]
[ValidateNotNull()]
Expand Down
8 changes: 4 additions & 4 deletions src/EventHub/EventHub.Autorest/custom/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Custom
This directory contains custom implementation for non-generated cmdlets for the `Az.EventHub` module. Both scripts (`.ps1`) and C# files (`.cs`) can be implemented here. They will be used during the build process in `build-module.ps1`, and create cmdlets into the `..\exports` folder. The only generated file into this folder is the `Az.EventHub.custom.psm1`. This file should not be modified.
This directory contains custom implementation for non-generated cmdlets for the `Az.EventHub` module. Both scripts (`.ps1`) and C# files (`.cs`) can be implemented here. They will be used during the build process in `build-module.ps1`, and create cmdlets into the `../exports` folder. The only generated file into this folder is the `Az.EventHub.custom.psm1`. This file should not be modified.

## Info
- Modifiable: yes
Expand All @@ -15,10 +15,10 @@ For C# cmdlets, they are compiled with the rest of the generated low-level cmdle
For script cmdlets, these are loaded via the `Az.EventHub.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundamental difference is the script cmdlets use the `ParameterSetName` attribute and C# cmdlets do not. To create a script cmdlet variant of a generated cmdlet, simply decorate all parameters in the script with the new `ParameterSetName` in the `Parameter` attribute. This will appropriately treat each parameter set as a separate variant when processed to be exported during the build.

## Purpose
This allows the modules to have cmdlets that were not defined in the REST specification. It also allows combining logic using generated cmdlets. This is a level of customization beyond what can be done using the [readme configuration options](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md) that are currently available. These custom cmdlets are then referenced by the cmdlets created at build-time in the `..\exports` folder.
This allows the modules to have cmdlets that were not defined in the REST specification. It also allows combining logic using generated cmdlets. This is a level of customization beyond what can be done using the [readme configuration options](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md) that are currently available. These custom cmdlets are then referenced by the cmdlets created at build-time in the `../exports` folder.

## Usage
The easiest way currently to start developing custom cmdlets is to copy an existing cmdlet. For C# cmdlets, copy one from the `generated/cmdlets` folder. For script cmdlets, build the project using `build-module.ps1` and copy one of the scripts from the `..\exports` folder. After that, if you want to add new parameter sets, follow the guidelines in the `Details` section above. For implementing a new cmdlets, at minimum, please keep these parameters:
The easiest way currently to start developing custom cmdlets is to copy an existing cmdlet. For C# cmdlets, copy one from the `generated/cmdlets` folder. For script cmdlets, build the project using `build-module.ps1` and copy one of the scripts from the `../exports` folder. After that, if you want to add new parameter sets, follow the guidelines in the `Details` section above. For implementing a new cmdlets, at minimum, please keep these parameters:
- Break
- DefaultProfile
- HttpPipelineAppend
Expand All @@ -36,6 +36,6 @@ For processing the cmdlets, we've created some additional attributes:
- `Microsoft.Azure.PowerShell.Cmdlets.EventHub.DoNotExportAttribute`
- Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Az.EventHub`.
- `Microsoft.Azure.PowerShell.Cmdlets.EventHub.InternalExportAttribute`
- Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.EventHub`. For more information, see [README.md](..\internal/README.md) in the `..\internal` folder.
- Used in C# cmdlets to route exported cmdlets to the `../internal`, which are *not exposed* by `Az.EventHub`. For more information, see [README.md](../internal/README.md) in the `../internal` folder.
- `Microsoft.Azure.PowerShell.Cmdlets.EventHub.ProfileAttribute`
- Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ function Set-AzEventHubNamespace{
[System.Int32]
${SkuCapacity},

[Parameter(HelpMessage = "The maximum acceptable lag for data replication operations from the primary replica to a quorum of secondary replicas. When the lag exceeds the configured amount, operations on the primary replica will be failed. The allowed values are 0 and 5 minutes to 1 day.")]
[Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')]
[System.Int64]
${GeoDataReplicationMaxReplicationLagDurationInSecond},

[Parameter(HelpMessage = "Properties for User Assigned Identities")]
[Microsoft.Azure.PowerShell.Cmdlets.EventHub.Models.INamespaceReplicaLocation[]]
${GeoDataReplicationLocation},

[Parameter(HelpMessage = "Tag of EventHub Namespace.")]
[Microsoft.Azure.PowerShell.Cmdlets.EventHub.Category('Body')]
[System.Collections.Hashtable]
Expand Down Expand Up @@ -188,6 +197,8 @@ function Set-AzEventHubNamespace{
$hasSkuCapacity = $PSBoundParameters.Remove('SkuCapacity')
$hasTag = $PSBoundParameters.Remove('Tag')
$hasAsJob = $PSBoundParameters.Remove('AsJob')
$hasGeoDataReplicationLocation = $PSBoundParameters.Remove('GeoDataReplicationLocation')
$hasGeoDataReplicationMaxReplicationLagDurationInSecond = $PSBoundParameters.Remove('GeoDataReplicationMaxReplicationLagDurationInSecond')
$null = $PSBoundParameters.Remove('WhatIf')
$null = $PSBoundParameters.Remove('Confirm')

Expand Down Expand Up @@ -225,6 +236,12 @@ function Set-AzEventHubNamespace{

$eventHubNamespace.UserAssignedIdentity = $identityHashTable
}
if ($GeoDataReplicationMaxReplicationLagDurationInSecond) {
$eventHubNamespace.GeoDataReplicationMaxReplicationLagDurationInSecond = $GeoDataReplicationMaxReplicationLagDurationInSecond
}
if ($GeoDataReplicationLocation) {
$eventHubNamespace.GeoDataReplicationLocation = $GeoDataReplicationLocation
}
if ($hasEnableAutoInflate) {
$eventHubNamespace.EnableAutoInflate = $EnableAutoInflate
}
Expand Down Expand Up @@ -256,4 +273,4 @@ function Set-AzEventHubNamespace{
throw
}
}
}
}
Loading