Skip to content

Commit

Permalink
Draft upgrade guide
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeminutillo committed Aug 23, 2021
1 parent 921176e commit 27df299
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
4 changes: 4 additions & 0 deletions menu/menu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,10 @@
Title: Version 7 to 8
- Url: nservicebus/upgrades/acs-host-6to7
Title: Version 6 to 7
- Title: Azure Functions with Service Bus
Articles:
- Url: nservicebus/upgrades/azure-functions-service-bus-1to2
Title: Version 1 to 2
- Title: Gateway
Articles:
- Url: nservicebus/upgrades/gateway-1to2
Expand Down
132 changes: 132 additions & 0 deletions nservicebus/upgrades/azure-functions-service-bus-1to2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
title: Azure Functions with Azure Service Bus Upgrade Version 1 to 2
summary: Instructions on how to upgrade Azure Functions with Azure Service Bus from version 1 to 2
component: ASBFunctions
reviewed: 2021-08-30
related:
- nservicebus/upgrades/7to8
isUpgradeGuide: true
upgradeGuideCoreVersions:
- 7
- 8
---

## Registering NServiceBus

All public constructors of `ServiceBusTriggeredEndpointConfiguration` have been made internal.

Instead of

```csharp
functionsHostBuilder.UseNServiceBus(() => new ServiceBusTriggeredEndpointConfiguration(endpointName));
```

Use:

```csharp
functionsHostBuilder.UseNServiceBus(endpointName);
```

Endpoint name can be inferred from `NServiceBusTriggerFunctionAttribute` if present.

```csharp
[assembly: NServiceBusTriggerFunction("MyEndpoint")]

// ...
functionsHostBuilder.UseNServiceBus(); // Will use the name MyEndpoint
```

NOTE: The constructed instance of `NServiceBusTriggeredEndpointConfiguration` already contains a reference to the `IConfiguration` from the host environment. It is not required to pass one in.

### Connection strings

Specifying a connection string by name has been deprecated.

Instead of

```csharp
functionsHostBuilder.UseNServiceBus(
() => new ServiceBusTriggeredEndpointConfiguration(endpointName, connectionStringName)
);
```

Use:

```csharp
functionsHostBuilder.UseNServiceBus(endpointName, nsb =>
{
var connectionString = Environment.GetEnvironmentVariable(connectionStringName);
nsb.ServiceBusConnectionString(connectionString);
});
```

### Routing

Instead of

```csharp
functionsHostBuilder.UseNServiceBus(() =>
{
var serviceBusTriggeredEndpointConfiguration = new ServiceBusTriggeredEndpointConfiguration(endpointName);
var routing = serviceBusTriggeredEndpointConfiguration.Transport.Routing();
routing.RouteToEndpoint(typeof(SomeMessage), "AnotherEndpoint");

return serviceBusTriiggeredEndpointConfiguration;
});
```

Use:

```csharp
functionsHostBuilder.UseNServiceBus(endpointName, nsb =>
{
nsb.Routing(routing => routing.RouteToEndpoint(typeof(SomeMessage), "AnotherEndpoint"));
});
```

### Transport configuration

Instead of

```csharp
functionsHostBuilder.UseNServiceBus(() =>
{
var serviceBusTriggeredEndpointConfiguration = new ServiceBusTriggeredEndpointConfiguration(endpointName);
var transport = serviceBusTriggeredEndpointConfiguration.Transport;
transport.TopicName("nsb-subs");
return serviceBusTriggeredEndpointConfiguration;
});
```

Use:

```csharp
functionsHostBuilder.UseNServiceBus(endpointName, nsb =>
{
nsb.ConfigureTransport(transport => transport.TopicName("nsb-subs"));
});
```

### Advanced configuration

Instead of

```csharp
functionsHostBuilder.UseNServiceBus(() =>
{
var serviceBusTriggeredEndpointConfiguration = new ServiceBusTriggeredEndpointConfiguration(endpointName);
var endpointConfiguration = serviceBusTriggeredEndpointConfiguration.AdvancedConfiguration;
endpointConfiguration.SendFailedMessagesTo("custom-error-queue");
return serviceBusTriggeredEndpointConfiguration;
});
```

Use:

```csharp
functionsHostBuilder.UseNServiceBus(endpointName, nsb =>
{
nsb.Advanced(endpointConfiguration => endpointConfiguration.SendFailedMessagesTo("custom-error-queue"));
});
```

0 comments on commit 27df299

Please sign in to comment.