-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Add EventHubs resources #42636
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
Merged
Merged
Add EventHubs resources #42636
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
sdk/provisioning/Azure.Provisioning/src/eventhubs/EventHub.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using Azure.Core; | ||
| using Azure.ResourceManager.EventHubs; | ||
| using Azure.ResourceManager.EventHubs.Models; | ||
|
|
||
| namespace Azure.Provisioning.EventHubs | ||
| { | ||
| /// <summary> | ||
| /// Represents an Event Hub. | ||
| /// </summary> | ||
| public class EventHub : Resource<EventHubData> | ||
| { | ||
| private const string ResourceTypeName = "Microsoft.EventHub/namespaces/eventhubs"; | ||
| private static readonly Func<string, EventHubData> Empty = (name) => ArmEventHubsModelFactory.EventHubData(); | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="EventHub"/>. | ||
| /// </summary> | ||
| /// <param name="scope">The scope.</param> | ||
| /// <param name="parent">The parent.</param> | ||
| /// <param name="name">The name.</param> | ||
| /// <param name="version">The version.</param> | ||
| /// <param name="location">The location.</param> | ||
| public EventHub(IConstruct scope, EventHubsNamespace? parent = null, string name = "hub", string version = EventHubsNamespace.DefaultVersion, AzureLocation? location = default) | ||
| : this(scope, parent, name, version, false, (name) => ArmEventHubsModelFactory.EventHubData( | ||
| name: name, | ||
| resourceType: ResourceTypeName, | ||
| location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS)) | ||
| { | ||
| } | ||
|
|
||
| private EventHub(IConstruct scope, EventHubsNamespace? parent = null, string name = "hub", string version = EventHubsNamespace.DefaultVersion, bool isExisting = true, Func<string, EventHubData>? creator = null) | ||
| : base(scope, parent, name, ResourceTypeName, EventHubsNamespace.DefaultVersion, creator ?? Empty, isExisting) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates a new instance of the <see cref="EventHub"/> class referencing an existing instance. | ||
| /// </summary> | ||
| /// <param name="scope">The scope.</param> | ||
| /// <param name="name">The resource name.</param> | ||
| /// <param name="parent">The resource group.</param> | ||
| /// <returns>The KeyVault instance.</returns> | ||
| public static EventHub FromExisting(IConstruct scope, string name, EventHubsNamespace parent) | ||
| => new EventHub(scope, parent: parent, name: name, isExisting: true); | ||
|
|
||
| /// <inheritdoc/> | ||
| protected override Resource? FindParentInScope(IConstruct scope) | ||
| { | ||
| return scope.GetSingleResource<EventHubsNamespace>() ?? new EventHubsNamespace(scope); | ||
| } | ||
| } | ||
| } |
59 changes: 59 additions & 0 deletions
59
sdk/provisioning/Azure.Provisioning/src/eventhubs/EventHubsNamespace.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using Azure.Core; | ||
| using Azure.Provisioning.ResourceManager; | ||
| using Azure.ResourceManager.EventHubs; | ||
| using Azure.ResourceManager.EventHubs.Models; | ||
|
|
||
| namespace Azure.Provisioning.EventHubs | ||
| { | ||
| /// <summary> | ||
| /// Represents an EventHubsNamespace. | ||
| /// </summary> | ||
| public class EventHubsNamespace : Resource<EventHubsNamespaceData> | ||
| { | ||
| private const string ResourceTypeName = "Microsoft.EventHub/namespaces"; | ||
| private static readonly Func<string, EventHubsNamespaceData> Empty = (name) => ArmEventHubsModelFactory.EventHubsNamespaceData(); | ||
| internal const string DefaultVersion = "2021-11-01"; | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="EventHubsNamespace"/>. | ||
| /// </summary> | ||
| /// <param name="scope">The scope.</param> | ||
| /// <param name="sku">The sku.</param> | ||
| /// <param name="parent">The parent.</param> | ||
| /// <param name="name">The name.</param> | ||
| /// <param name="version">The version.</param> | ||
| /// <param name="location">The location.</param> | ||
| public EventHubsNamespace(IConstruct scope, EventHubsSku? sku = default, ResourceGroup? parent = null, string name = "eh", string version = DefaultVersion, AzureLocation? location = default) | ||
| : this(scope, parent, name, version, false, (name) => ArmEventHubsModelFactory.EventHubsNamespaceData( | ||
| name: name, | ||
| resourceType: ResourceTypeName, | ||
| location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, | ||
| sku: sku ?? new EventHubsSku(EventHubsSkuName.Standard), | ||
| minimumTlsVersion: EventHubsTlsVersion.Tls1_2)) | ||
| { | ||
| AssignProperty(data => data.Name, GetAzureName(scope, name)); | ||
| } | ||
|
|
||
| private EventHubsNamespace(IConstruct scope, ResourceGroup? parent = null, string name = "eh", string version = DefaultVersion, bool isExisting = true, Func<string, EventHubsNamespaceData>? creator = null) | ||
| : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates a new instance of the <see cref="EventHubsNamespace"/> class referencing an existing instance. | ||
| /// </summary> | ||
| /// <param name="scope">The scope.</param> | ||
| /// <param name="name">The resource name.</param> | ||
| /// <param name="parent">The resource group.</param> | ||
| /// <returns>The KeyVault instance.</returns> | ||
| public static EventHubsNamespace FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) | ||
| => new EventHubsNamespace(scope, parent: parent, name: name, isExisting: true); | ||
|
|
||
| /// <inheritdoc/> | ||
| protected override string GetAzureName(IConstruct scope, string resourceName) => GetGloballyUniqueName(resourceName); | ||
| } | ||
| } |
42 changes: 42 additions & 0 deletions
42
sdk/provisioning/Azure.Provisioning/tests/Infrastructure/EventHubs/main.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| targetScope = 'resourceGroup' | ||
|
|
||
| @description('') | ||
| param location string = resourceGroup().location | ||
|
|
||
|
|
||
| resource eventHubsNamespace_LmeDkjUWO 'Microsoft.EventHub/namespaces@2021-11-01' = { | ||
| name: toLower(take(concat('eh', uniqueString(resourceGroup().id)), 24)) | ||
| location: location | ||
| sku: { | ||
| name: 'Standard' | ||
| } | ||
| properties: { | ||
| minimumTlsVersion: '1.2' | ||
| } | ||
| } | ||
|
|
||
| resource eventHub_ELtptvi1s 'Microsoft.EventHub/namespaces/eventhubs@2021-11-01' = { | ||
| parent: eventHubsNamespace_LmeDkjUWO | ||
| name: 'hub' | ||
| location: location | ||
| properties: { | ||
| } | ||
| } | ||
|
|
||
| resource eventHubConsumerGroup_gMkCNeWuK 'Microsoft.EventHub/namespaces/eventhubs/consumergroups@2021-11-01' = { | ||
| parent: eventHub_ELtptvi1s | ||
| name: 'hub' | ||
| location: location | ||
| properties: { | ||
| } | ||
| } | ||
|
|
||
| resource roleAssignment_oj7e7rOUf 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
| scope: eventHubsNamespace_LmeDkjUWO | ||
| name: guid(eventHubsNamespace_LmeDkjUWO.id, '00000000-0000-0000-0000-000000000000', subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f526a384-b230-433a-b45c-95f59c4a2dec')) | ||
| properties: { | ||
| roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'f526a384-b230-433a-b45c-95f59c4a2dec') | ||
| principalId: '00000000-0000-0000-0000-000000000000' | ||
| principalType: 'ServicePrincipal' | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.