-
Notifications
You must be signed in to change notification settings - Fork 0
Deploying Service Endpoints
As you have seen in the previous articles the Solution takes care about registering step, not the underlying Event Handlers.
Therefore you need to deploy the Event Handlers yourself, for example through your solution. For Plugin Types this is easy, register your Types when uploading the assembly, add them to the solution and they will be in the export of the solution.
For Service Endpoints the situation is a little bit more cloudy. Basicially the same thing applies for the Service Endpoint, but when exporting you will find that the Service Bus Namespace/Path is included but the SASKey is not.
When importing to the production instance your Service Endpoint will therefore write to the same Queue/Topic as the development enviroment. Additionally the first time you deploy you will have to enter the SASKey the first time you import the solution to the instance.
From a DevOps perspective this is very suboptimal, therefore we need a solution.
Wael Hamzes Power DevOps Tools offer us a task "Service Endpoint Registration", however it requires a mapping file and I was unable to find any bit of information about it. To conserve and share the knowledge gained from digging in the repository, here is a little tutorial on how to use this tool to register or manipulate an existing Service Endpoint to set correct values in an Azure DevOps Pipeline.
If you have never registered a service endpoint, I suggest you start of with this Microsoft Tutorial to get to know the process behind.
First the task seems simple, add a connection string and a mapping file.
But the big question I couldn't find an answer for was: What belongs in the json? Well here is an example
[
{
"Id": "E4C93BA1-0BE2-4E3F-AB81-0A704DF4FF29",
"Name": "MyServiceEndpoint",
"NamespaceAddress": "sb://myservicebus.servicebus.windows.net/",
"Contract": "Topic",
"Path": "remotecontext",
"MessageFormat": "JSON",
"AuthType": "SASKey",
"SASKeyName": "RootManageSharedAccessKey",
"SASKey": "mySecret",
"UserClaim": "UserId",
"Description": "",
"Url": null,
"AuthValue": null,
"Steps": []
}
]
And thats it. Run it and it will Upsert the Endpoint if you entered valid data and a valid connection string.
The ServiceEndpt Class defining the JSON you find above, check the same folder and the Common/Entities folder for the related objects like the Optionset "Contract" and the definition of the "Steps". Also when we check the UpsertServiceEndpoint method of the PluginRegistrationHelper we find that it is indeed a simple upsert of the entity serviceendpoint. Therefore something like this should work fine for updating the Namespace and SASKey in a script, if for example you would retrieve a connection string from a keyvault and would not want to use the mapping file:
var svcenpt = new Entity("serviceendpoint", new Guid("E4C93BA1-0BE2-4E3F-AB81-0A704DF4FF29"));
svcenpt.Attributes.Add("namespaceaddress", "sb://myservicebus.servicebus.windows.net/");
svcenpt.Attributes.Add("saskey", "mySecret");
OrgService.Update(svcenpt);