Automated Creation of Event Subscription for Azure Health Data Service

Jack Kurtz 21 Reputation points
2022-12-07T14:42:37.227+00:00

I am trying to automate the creation of a Web Hook Event Subscription for an Azure Health Data Service by using an Azure Resource Manage Template with the Azure SDK for Go. I started with this tutorial - https://learn.microsoft.com/en-us/azure/developer/go/deploy-azure-resource-manager-template - and was able to create the Storage Account successfully. Then I used the quick start template for a Web Hook Event Subscription, found here https://github.com/Azure/azure-quickstart-templates/blob/master/quickstarts/microsoft.eventgrid/event-grid-resource-events-to-webhook/azuredeploy.json, and was able to create the generic Event Subscription successfully. However, when I tried to use the template for the Web Hook Event Subscription for Azure Health Data Service, provided by the Advanced Editor tab, which looks like this:

{
"name": "{event-sub-name}",
"properties": {
"topic": "{ahds-topic-id}",
"destination": {
"endpointType": "WebHook",
"properties": null
},
"filter": {
"includedEventTypes": [
"Microsoft.HealthcareApis.FhirResourceCreated",
"Microsoft.HealthcareApis.FhirResourceUpdated",
"Microsoft.HealthcareApis.FhirResourceDeleted"
],
"advancedFilters": [],
"enableAdvancedFilteringOnArrays": true
},
"labels": [],
"eventDeliverySchema": "EventGridSchema"
}
}

I get the following error:

{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"InvalidRequest","message":"The specified topic property does not match the expected topic from the event subscription scope."}]}

Is it possible to automate the creation of a Web Hook Event Subscription for an Azure Health Data service by using an Azure Resource Manage Template with the Azure SDK for Go? If yes, how can I resolve this error?

Azure Event Grid
Azure Event Grid
An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
402 questions
0 comments No comments
{count} votes

Accepted answer
  1. JananiRamesh-MSFT 29,116 Reputation points
    2022-12-08T16:48:14.87+00:00

    Hi @Jack Kurtz Thanks for reaching out. As per the Azure documentation , "Microsoft.EventGrid/eventSubscriptions doesn't have any property like topic thats why your arm template deployment got failed with this error.

    could you please try using the below template, in this case I had created Event grid subscription for an already existing Health Data Services workspace. If you need to create a workspace you can include that resource in the below template https://learn.microsoft.com/en-us/azure/healthcare-apis/fhir/fhir-service-resource-manager-template?tabs=PowerShell#review-the-arm-template

    {  
        "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",  
        "contentVersion": "1.0.0.0",  
        "parameters": {  
            "FHIRName": {  
                "type": "String"  
            },  
            "eventSubName": {  
                "type": "String"  
            },  
            "endpoint": {  
                "type": "String"  
            }  
        },  
        "variables": {},  
        "resources": [  
            {  
                "type": "Microsoft.HealthcareApis/workspaces/providers/eventSubscriptions",  
                "apiVersion": "2018-01-01",  
                "name": "[concat(parameters('FHIRName'), '/Microsoft.EventGrid/', parameters('eventSubName'))]",  
                "properties": {  
                    "destination": {  
                        "endpointType": "WebHook",  
                        "properties": {  
                            "endpointUrl": "[parameters('endpoint')]"  
                        }  
                    },  
                    "filter": {  
                        "subjectBeginsWith": "",  
                        "subjectEndsWith": "",  
                        "isSubjectCaseSensitive": false,  
                        "includedEventTypes": [  
                            "All"  
                        ]  
                    }  
                }  
            }  
        ],  
        "outputs": {}  
    }  
    

    do let me know incase of further queries, I would be happy to assist you.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Jack Kurtz 21 Reputation points
    2022-12-15T16:50:22.683+00:00

    This template was successful except for

    "includedEventTypes": [  
                             "All"  
                         ]  
    

    due to the following error:

    {"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"InvalidRequest","message":"Invalid filter: The All EventType is being discontinued. Set the IncludedEventTypes to null to get all the default event types."}]}  
    

    I changed the template to

    "includedEventTypes": null  
    

    and was successful. I also had success specifying my included events like so:

    "includedEventTypes": [  
        "Microsoft.HealthcareApis.FhirResourceCreated",  
        "Microsoft.HealthcareApis.FhirResourceUpdated",  
        "Microsoft.HealthcareApis.FhirResourceDeleted"  
    ]  
    

    Thank you!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.