Azure.ResourceManager.EventHubs 1.0.0-beta.4

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
.NET Standard 2.0
This is a prerelease version of Azure.ResourceManager.EventHubs.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Azure.ResourceManager.EventHubs --version 1.0.0-beta.4
NuGet\Install-Package Azure.ResourceManager.EventHubs -Version 1.0.0-beta.4
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Azure.ResourceManager.EventHubs" Version="1.0.0-beta.4" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Azure.ResourceManager.EventHubs --version 1.0.0-beta.4
#r "nuget: Azure.ResourceManager.EventHubs, 1.0.0-beta.4"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Azure.ResourceManager.EventHubs as a Cake Addin
#addin nuget:?package=Azure.ResourceManager.EventHubs&version=1.0.0-beta.4&prerelease

// Install Azure.ResourceManager.EventHubs as a Cake Tool
#tool nuget:?package=Azure.ResourceManager.EventHubs&version=1.0.0-beta.4&prerelease

Azure Event Hubs Management client library for .NET

This package follows the new Azure SDK guidelines which provide a number of core capabilities that are shared amongst all Azure SDKs, including the intuitive Azure Identity library, an HTTP Pipeline with custom policies, error-handling, distributed tracing, and much more.

Getting started

Install the package

Install the Azure EventHubs management library for .NET with NuGet:

Install-Package Azure.ResourceManager.EventHubs -Version 1.0.0-beta.3

Prerequisites

Set up a way to authenticate to Azure with Azure Identity.

Some options are:

More information and different authentication approaches using Azure Identity can be found in this document.

Authenticate the Client

The default option to create an authenticated client is to use DefaultAzureCredential. Since all management APIs go through the same endpoint, in order to interact with resources, only one top-level ArmClient has to be created.

To authenticate to Azure and create an ArmClient, do the following:

using Azure.Identity;
ArmClient armClient = new ArmClient(new DefaultAzureCredential());

Additional documentation for the Azure.Identity.DefaultAzureCredential class can be found in this document.

Key concepts

Key concepts of the Azure .NET SDK can be found here

Examples

Create a namespace

Before creating a namespace, we need to have a resource group.

ArmClient armClient = new ArmClient(new DefaultAzureCredential());
SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();
string rgName = "myRgName";
AzureLocation location = AzureLocation.WestUS2;
ArmOperation<ResourceGroupResource> operation = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, new ResourceGroupData(location));
ResourceGroupResource resourceGroup = operation.Value;

Then we can create a namespace inside this resource group.

string namespaceName = "myNamespace";
EventHubNamespaceCollection namespaceCollection = resourceGroup.GetEventHubNamespaces();
AzureLocation location = AzureLocation.EastUS2;
EventHubNamespaceResource eventHubNamespace = (await namespaceCollection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName, new EventHubNamespaceData(location))).Value;

Get all namespaces in a resource group

EventHubNamespaceCollection namespaceCollection = resourceGroup.GetEventHubNamespaces();
await foreach (EventHubNamespaceResource eventHubNamespace in namespaceCollection.GetAllAsync())
{
    Console.WriteLine(eventHubNamespace.Id.Name);
}

Get a namespace

EventHubNamespaceCollection namespaceCollection = resourceGroup.GetEventHubNamespaces();
EventHubNamespaceResource eventHubNamespace = await namespaceCollection.GetAsync("myNamespace");
Console.WriteLine(eventHubNamespace.Id.Name);

Delete a namespace

EventHubNamespaceCollection namespaceCollection = resourceGroup.GetEventHubNamespaces();
EventHubNamespaceResource eventHubNamespace = await namespaceCollection.GetAsync("myNamespace");
await eventHubNamespace.DeleteAsync(WaitUntil.Completed);

Add a tag to the namespace

EventHubNamespaceCollection namespaceCollection = resourceGroup.GetEventHubNamespaces();
EventHubNamespaceResource eventHubNamespace = await namespaceCollection.GetAsync("myNamespace");
await eventHubNamespace.AddTagAsync("key","value");

For more detailed examples, take a look at samples we have available.

Troubleshooting

Next steps

More sample code

Additional Documentation

For more information on Azure SDK, please refer to this website.

Contributing

For details on contributing to this repository, see the contributing guide.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows
.NET Core netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard2.0 netstandard2.1
.NET Framework net461 net462 net463 net47 net471 net472 net48 net481
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen40 tizen60
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Azure.ResourceManager.EventHubs:

Repository Stars
Azure/azure-functions-kafka-extension
Kafka extension for Azure Functions
Version Downloads Last updated
1.0.0 18,557 7/21/2022
1.0.0-beta.4 10,290 4/8/2022
1.0.0-beta.3 168 3/31/2022