Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ description: Samples for the Azure.Messaging.EventGrid.Namespaces client library
Before starting, take a look at the Azure Event Grid [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/README.md) for more information on how to create an Event Grid custom topic or domain using the Azure portal/Azure CLI, and retrieving the designated endpoint and credential.

- [Using Namespace Topics](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/Sample1_Namespaces.md)
- [Using the Cloud Native CloudEvent type]
- [Using the Cloud Native CloudEvent type](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/eventgrid/Azure.Messaging.EventGrid.Namespaces/samples/Sample2_CNCF.md)
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
<DisableEnhancedAnalysis>true</DisableEnhancedAnalysis>
</PropertyGroup>

<ItemGroup>
<ItemGroup>
<Compile Include="$(AzureCoreSharedSources)AzureKeyCredentialPolicy.cs" LinkBase="Shared/Core" />
<Compile Include="$(AzureCoreSharedSources)AzureResourceProviderNamespaceAttribute.cs" LinkBase="Shared/Core" />
<Compile Include="..\..\..\core\Azure.Core\src\Shared\AzureKeyCredentialPolicy.cs">
<Link>Shared\Core\AzureKeyCredentialPolicy.cs</Link>
</Compile>
</ItemGroup>

<ItemGroup>
<Compile Include="$(AzureEventGridSharedSources)CloudEventRequestContent.cs" LinkBase="Shared/EventGrid" />
<Compile Include="$(AzureEventGridSharedSources)CloudEventsRequestContent.cs" LinkBase="Shared/EventGrid" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Core" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Azure.Messaging.EventGrid.Namespaces
public partial class EventGridSenderClient
{
private readonly string _topicName;
private readonly bool _isDistributedTracingEnabled;

/// <summary> Initializes a new instance of EventGridSenderClient. </summary>
/// <param name="endpoint"> The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net. </param>
Expand Down Expand Up @@ -66,6 +67,7 @@ public EventGridSenderClient(Uri endpoint,
_endpoint = endpoint;
_apiVersion = options.Version;
_topicName = topicName;
_isDistributedTracingEnabled = options.Diagnostics.IsDistributedTracingEnabled;
}

/// <summary> Initializes a new instance of EventGridSenderClient. </summary>
Expand Down Expand Up @@ -93,6 +95,7 @@ public EventGridSenderClient(Uri endpoint,
_endpoint = endpoint;
_apiVersion = options.Version;
_topicName = topicName;
_isDistributedTracingEnabled = options.Diagnostics.IsDistributedTracingEnabled;
}

/// <summary> Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. </summary>
Expand All @@ -104,7 +107,7 @@ public virtual Response Send(CloudEvent cloudEvent, CancellationToken cancellati
Argument.AssertNotNull(cloudEvent, nameof(cloudEvent));

RequestContext context = FromCancellationToken(cancellationToken);
return Send(_topicName, RequestContent.Create(cloudEvent), context);
return Send(_topicName, new CloudEventRequestContent(cloudEvent, _isDistributedTracingEnabled), context);
}

/// <summary> Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. </summary>
Expand All @@ -118,7 +121,7 @@ public virtual async Task<Response> SendAsync(
Argument.AssertNotNull(cloudEvent, nameof(cloudEvent));

RequestContext context = FromCancellationToken(cancellationToken);
return await SendAsync(_topicName, RequestContent.Create(cloudEvent), context).ConfigureAwait(false);
return await SendAsync(_topicName, new CloudEventRequestContent(cloudEvent, _isDistributedTracingEnabled), context).ConfigureAwait(false);
}

/// <summary> Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. </summary>
Expand All @@ -136,7 +139,7 @@ public virtual async Task<Response> SendAsync(IEnumerable<CloudEvent> cloudEvent
scope.Start();
try
{
return await SendEventsAsync(_topicName, RequestContent.Create(cloudEvents), context).ConfigureAwait(false);
return await SendEventsAsync(_topicName, new CloudEventsRequestContent(cloudEvents, _isDistributedTracingEnabled), context).ConfigureAwait(false);
}
catch (Exception e)
{
Expand All @@ -160,7 +163,7 @@ public virtual Response Send(IEnumerable<CloudEvent> cloudEvents, CancellationTo
scope.Start();
try
{
return SendEvents(_topicName, RequestContent.Create(cloudEvents), context);
return SendEvents(_topicName, new CloudEventsRequestContent(cloudEvents, _isDistributedTracingEnabled), context);
}
catch (Exception e)
{
Expand Down
Loading