-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
921176e
commit 27df299
Showing
2 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
132 changes: 132 additions & 0 deletions
132
nservicebus/upgrades/azure-functions-service-bus-1to2.md
This file contains 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,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")); | ||
}); | ||
``` |