### Start with Docker Compose Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Aspire Navigate to the 'docker' directory and use docker-compose to start the simulator and its dependencies if not using Aspire. ```bash cd docker docker-compose up --build ``` -------------------------------- ### Complete Configuration Example Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Retry-and-Dead-Letter A comprehensive example demonstrating the configuration of topics, subscribers, retry policies, and dead-letter settings within the simulator. ```json { "topics": [ { "name": "OrdersTopic", "port": 60101, "key": "TheLocal+DevelopmentKey=", "subscribers": { "http": [ { "name": "MyWebhook", "endpoint": "https://myapp.com/webhooks/orders", "disableValidation": true, "retryPolicy": { "enabled": true, "maxDeliveryAttempts": 10, "eventTimeToLiveInMinutes": 60 }, "deadLetter": { "enabled": true, "folderPath": "./dead-letters" } } ] } } ] } ``` -------------------------------- ### Install Azure Event Grid Simulator Globally Source: https://github.com/pm7y/azureeventgridsimulator/wiki/DotNet-Tool Install the tool globally to make it available from any directory. ```bash dotnet tool install -g AzureEventGridSimulator ``` -------------------------------- ### Complete Service Bus Subscriber Configuration Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Service-Bus-Subscribers A full example demonstrating the setup of a Service Bus subscriber with topic configuration, connection string, and custom property mapping. ```json { "topics": [ { "name": "OrdersTopic", "port": 60101, "key": "TheLocal+DevelopmentKey=", "serviceBusConnectionString": "Endpoint=sb://my-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=...", "subscribers": { "serviceBus": [ { "name": "OrdersQueueSubscription", "queue": "orders-queue", "properties": { "OrderId": { "type": "dynamic", "value": "data.orderId" }, "EventType": { "type": "dynamic", "value": "EventType" }, "Source": { "type": "static", "value": "EventGridSimulator" } } } ] } } ] } ``` -------------------------------- ### Start the Aspire AppHost Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Aspire Navigate to the 'src' directory and run the AppHost project to start the Azure Event Grid Simulator and its dependencies. ```bash cd src dotnet run --project AzureEventGridSimulator.AppHost ``` -------------------------------- ### Configure Simulator with appsettings.json Source: https://github.com/pm7y/azureeventgridsimulator/wiki/DotNet-Tool Example of an appsettings.json file to configure topics and subscribers for the simulator. ```json { "topics": [ { "name": "MyTopic", "port": 60101, "key": "TheLocal+DevelopmentKey=", "subscribers": [ { "name": "MySubscriber", "endpoint": "http://localhost:7071/api/MyFunction", "disableValidation": true } ] } ] } ``` -------------------------------- ### Install Azure Event Grid Simulator Locally Source: https://github.com/pm7y/azureeventgridsimulator/wiki/DotNet-Tool Install the tool locally within a project. This requires initializing a tool manifest first. ```bash dotnet new tool-manifest dotnet tool install AzureEventGridSimulator ``` -------------------------------- ### Configure Simulator Topics Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Troubleshooting Example configuration for defining topics in `appsettings.json`. Ensure the topic name and port are correctly specified. ```json { "topics": [ { "name": "MyTopic", "port": 60101 } ] } ``` -------------------------------- ### Install Azure Event Grid Simulator as a .NET Global Tool Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/README.md Installs the simulator globally on your machine using the .NET CLI. You can then run it directly. ```bash dotnet tool install -g AzureEventGridSimulator azure-eventgrid-simulator ``` -------------------------------- ### Complete Configuration Example Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Configuration An extensive JSON configuration demonstrating a topic with multiple subscriber types, including filters, properties, and connection string inheritance. ```json { "topics": [ { "name": "OrdersTopic", "port": 60101, "key": "TheLocal+DevelopmentKey=", "serviceBusConnectionString": "Endpoint=sb://my-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=...", "storageQueueConnectionString": "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=...;EndpointSuffix=core.windows.net", "eventHubConnectionString": "Endpoint=sb://my-eventhub-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=...", "subscribers": { "http": [ { "name": "WebhookSubscription", "endpoint": "https://myapp.com/webhooks/orders", "disableValidation": true, "filter": { "includedEventTypes": ["Order.Created", "Order.Updated"] } } ], "serviceBus": [ { "name": "OrdersQueueSubscription", "queue": "orders-queue", "properties": { "OrderId": { "type": "dynamic", "value": "data.orderId" }, "EventType": { "type": "dynamic", "value": "EventType" }, "Source": { "type": "static", "value": "EventGridSimulator" } } } ], "storageQueue": [ { "name": "OrdersStorageQueueSubscription", "queueName": "orders-archive" } ], "eventHub": [ { "name": "OrdersEventHubSubscription", "eventHubName": "orders-events", "deliverySchema": "CloudEventV1_0", "properties": { "OrderId": { "type": "dynamic", "value": "data.orderId" }, "Region": { "type": "static", "value": "west-us" } } } ] } } ] } ``` -------------------------------- ### Run Azure Event Grid Simulator Globally Source: https://github.com/pm7y/azureeventgridsimulator/wiki/DotNet-Tool Execute the globally installed simulator. ```bash azure-eventgrid-simulator ``` -------------------------------- ### Unit Test Example Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/AGENTS.md An example of a unit test using xUnit, Shouldly, and NSubstitute. Tests are categorized using Traits. ```csharp [Trait("Category", "unit")] // or "integration" public class MyTests { [Fact] public void Should_DoX_When_Y() { // Arrange/Act/Assert with Shouldly result.ShouldBe(expected); } } ``` -------------------------------- ### Event Grid Schema Example Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md An example of the JSON structure for events conforming to the Event Grid Schema. ```json [ { "id": "unique-event-id", "subject": "/orders/12345", "eventType": "Order.Created", "eventTime": "2025-01-15T10:30:00Z", "data": { "orderId": "12345", "amount": 99.99 }, "dataVersion": "1.0" } ] ``` -------------------------------- ### Basic Topic and Subscriber Configuration Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Configuration An example demonstrating the configuration of a single topic with one subscriber. This is useful for setting up a basic local development environment. ```json { "topics": [ { "name": "MyAwesomeTopic", "port": 60101, "key": "TheLocal+DevelopmentKey=", "subscribers": [ { "name": "LocalAzureFunctionSubscription", "endpoint": "http://localhost:7071/runtime/webhooks/EventGrid?functionName=PersistEventToDb", "disableValidation": true } ] } ] } ``` -------------------------------- ### Conventional Commit Examples Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Contributing Examples of valid commit messages following the Conventional Commits specification. ```git feat: add Azure Storage Queue subscriber support fix: correct retry delay calculation docs: update configuration examples chore: update dependencies ``` -------------------------------- ### Docker Compose Basic Setup Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Basic Docker Compose configuration for the Event Grid Simulator. Includes port mapping, volume mounts for certificates and configuration, and environment variables for HTTPS. ```yaml # docker-compose.yml services: eventgrid: image: pmcilreavy/azureeventgridsimulator:latest ports: - "60101:60101" volumes: - ./certs:/certs:ro - ./config:/config:ro environment: - ASPNETCORE_Kestrel__Certificates__Default__Path=/certs/eventgrid.pfx - ASPNETCORE_Kestrel__Certificates__Default__Password=password123 - AEGS_ConfigFile=/config/appsettings.json ``` -------------------------------- ### CloudEvents Schema Example Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md An example of the JSON structure for events conforming to the CloudEvents Schema. ```json [ { "specversion": "1.0", "id": "unique-event-id", "source": "/orders", "type": "Order.Created", "time": "2025-01-15T10:30:00Z", "data": { "orderId": "12345", "amount": 99.99 } } ] ``` -------------------------------- ### Complete Subscriber Configuration with Array Filtering Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Filtering A full configuration example for a subscriber, demonstrating how to enable advanced filtering on arrays to match events based on array content. ```json { "topics": [ { "name": "OrdersTopic", "port": 60101, "key": "TheLocal+DevelopmentKey=", "subscribers": [ { "name": "HighPriorityOrders", "endpoint": "http://localhost:7071/api/ProcessHighPriority", "filter": { "enableAdvancedFilteringOnArrays": true, "advancedFilters": [ { "operatorType": "StringIn", "key": "Data.Categories", "values": ["premium", "vip"] } ] } } ] } ] } ``` -------------------------------- ### Run Simulator with Mounted Config File Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Starts the simulator container, mounting a local configuration directory and specifying the config file path via an environment variable. ```bash docker run -d \ -v /path/to/config:/config:ro \ -e AEGS_ConfigFile=/config/appsettings.json \ pmcilreavy/azureeventgridsimulator:latest ``` -------------------------------- ### Container Networking Example Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md JSON configuration for specifying a subscriber endpoint when it runs in another Docker container. ```json { "endpoint": "https://myapp:5000/webhook" } ``` -------------------------------- ### Run Azure Event Grid Simulator Locally Source: https://github.com/pm7y/azureeventgridsimulator/wiki/DotNet-Tool Execute the locally installed simulator using the 'dotnet tool run' command. ```bash dotnet tool run azure-eventgrid-simulator ``` -------------------------------- ### Example: Multiple Topics Configuration Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Defines two distinct topics, 'orders-topic' and 'notifications-topic', each with its own port, SAS key, and input schema type. This JSON structure is used for appsettings.json. ```json { "topics": [ { "name": "orders-topic", "port": 60101, "key": "OrdersTopicKey=", "inputSchema": "EventGridSchema", "subscribers": { } }, { "name": "notifications-topic", "port": 60102, "key": "NotificationsKey=", "inputSchema": "CloudEventV1_0", "subscribers": { } } ] } ``` -------------------------------- ### Basic Storage Queue Subscriber Configuration Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Storage-Queue-Subscribers A basic example of configuring a Storage Queue subscriber with its name, connection string, and queue name. ```json { "subscribers": { "storageQueue": [ { "name": "OrdersArchive", "connectionString": "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=...;EndpointSuffix=core.windows.net", "queueName": "orders-archive" } ] } } ``` -------------------------------- ### Complete Example of Event Subscription Filtering Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Filtering This JSON configuration demonstrates how to set up an event subscription with various filters, including included event types, subject prefix matching, and advanced number-based filtering. ```json { "topics": [ { "name": "MyAwesomeTopic", "port": 60101, "key": "TheLocal+DevelopmentKey=", "subscribers": [ { "name": "LocalAzureFunctionSubscription", "endpoint": "http://localhost:7071/runtime/webhooks/EventGrid?functionName=PersistEventToDb", "filter": { "includedEventTypes": ["my.eventType"], "subjectBeginsWith": "/orders/", "advancedFilters": [ { "operatorType": "NumberGreaterThanOrEquals", "key": "Data.Amount", "value": 100 } ] } } ] } ] } ``` -------------------------------- ### Docker Volume Mount for Dead-Letters Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Example of mounting a local directory as a volume in Docker to persist dead-letter files. ```bash -v $(pwd)/dead-letters:/app/dead-letters ``` -------------------------------- ### Update Azure Event Grid Simulator Globally Source: https://github.com/pm7y/azureeventgridsimulator/wiki/DotNet-Tool Update the globally installed .NET tool to the latest version. ```bash dotnet tool update -g AzureEventGridSimulator ``` -------------------------------- ### Complete Storage Queue Subscriber Configuration Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Storage-Queue-Subscribers A comprehensive example showing a Storage Queue subscriber with topic configuration, delivery schema, and retry policy. ```json { "topics": [ { "name": "OrdersTopic", "port": 60101, "key": "TheLocal+DevelopmentKey=", "storageQueueConnectionString": "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=...;EndpointSuffix=core.windows.net", "subscribers": { "storageQueue": [ { "name": "OrdersStorageQueueSubscription", "queueName": "orders-archive", "deliverySchema": "CloudEventV1_0", "retryPolicy": { "enabled": true, "maxDeliveryAttempts": 5 } } ] } } ] } ``` -------------------------------- ### Complete HTTP Subscriber Configuration Source: https://github.com/pm7y/azureeventgridsimulator/wiki/HTTP-Subscribers A comprehensive example demonstrating advanced HTTP subscriber settings including filtering, retry policy, and dead-letter configuration. ```json { "topics": [ { "name": "OrdersTopic", "port": 60101, "key": "TheLocal+DevelopmentKey=", "subscribers": { "http": [ { "name": "OrdersWebhook", "endpoint": "https://myapp.com/webhooks/orders", "disableValidation": true, "filter": { "includedEventTypes": ["Order.Created", "Order.Updated"] }, "retryPolicy": { "enabled": true, "maxDeliveryAttempts": 10, "eventTimeToLiveInMinutes": 60 }, "deadLetter": { "enabled": true, "folderPath": "./dead-letters" } } ] } } ] } ``` -------------------------------- ### Update Azure Event Grid Simulator Locally Source: https://github.com/pm7y/azureeventgridsimulator/wiki/DotNet-Tool Update the locally installed .NET tool within the current project. ```bash dotnet tool update AzureEventGridSimulator ``` -------------------------------- ### Uninstall Azure Event Grid Simulator Locally Source: https://github.com/pm7y/azureeventgridsimulator/wiki/DotNet-Tool Remove the locally installed .NET tool from the current project. ```bash dotnet tool uninstall AzureEventGridSimulator ``` -------------------------------- ### Uninstall Azure Event Grid Simulator Globally Source: https://github.com/pm7y/azureeventgridsimulator/wiki/DotNet-Tool Remove the globally installed .NET tool. ```bash dotnet tool uninstall -g AzureEventGridSimulator ``` -------------------------------- ### Basic Service Bus Subscriber Configuration Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Service-Bus-Subscribers A basic example demonstrating how to configure a Service Bus subscriber to send events to a specific queue using a connection string. ```json { "subscribers": { "serviceBus": [ { "name": "OrdersQueue", "connectionString": "Endpoint=sb://my-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=...", "queue": "orders-queue" } ] } } ``` -------------------------------- ### Configure Event Subscription Filter Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Troubleshooting Example of an event subscription filter configuration. Use this to specify which event types a subscriber should receive. ```json { "filter": { "includedEventTypes": ["Order.Created"] } } ``` -------------------------------- ### Run Azure Event Grid Simulator Docker Container Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Starts the simulator in detached mode, mapping ports and mounting local directories for certificates and configuration. Environment variables configure HTTPS certificates and the config file path. ```bash docker run -d \ --name eventgrid \ -p 60101:60101 \ -v $(pwd)/certs:/certs:ro \ -v $(pwd)/config:/config:ro \ -e ASPNETCORE_Kestrel__Certificates__Default__Path=/certs/eventgrid.pfx \ -e ASPNETCORE_Kestrel__Certificates__Default__Password=password123 \ -e AEGS_ConfigFile=/config/appsettings.json \ pmcilreavy/azureeventgridsimulator:latest ``` -------------------------------- ### Example Event Data for Array Filtering Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Filtering Illustrates the structure of an event containing an array property, used to demonstrate array filtering behavior. ```json { "data": { "tags": ["urgent", "customer", "billing"] } } ``` -------------------------------- ### Create HTTPS Certificate for Docker Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Docker Generates a PFX certificate file required for HTTPS communication within the Docker environment. This command should be run locally before starting the Docker container. ```bash dotnet dev-certs https --export-path ./docker/azureEventGridSimulator.pfx --password Y0urSup3rCrypt1cPa55w0rd! ``` -------------------------------- ### Run Docker Container with Environment Variables Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Docker Launches the Azure Event Grid Simulator in a detached Docker container, publishing port 60101 and configuring topics and HTTP subscribers via environment variables. Ensure the certificate path and password match your local setup. ```bash docker run \ --detach \ --publish 60101:60101 \ -v $(pwd)/docker:/aegs \ -e ASPNETCORE_ENVIRONMENT=Development \ -e ASPNETCORE_Kestrel__Certificates__Default__Path=/aegs/azureEventGridSimulator.pfx \ -e ASPNETCORE_Kestrel__Certificates__Default__Password=Y0urSup3rCrypt1cPa55w0rd! \ -e TZ=Australia/Brisbane \ -e AEGS_topics__0__name=ExampleTopic \ -e AEGS_topics__0__port=60101 \ -e AEGS_topics__0__key=TheLocal+DevelopmentKey= \ -e AEGS_topics__0__subscribers__http__0__name=RequestCatcherSubscription \ -e AEGS_topics__0__subscribers__http__0__endpoint=https://azureeventgridsimulator.requestcatcher.com/ \ -e AEGS_topics__0__subscribers__http__0__disableValidation=true \ -e AEGS_topics__0__subscribers__http__1__name=AzureFunctionSubscription \ -e AEGS_topics__0__subscribers__http__1__endpoint=http://host.docker.internal:7071/runtime/webhooks/EventGrid?functionName=ExampleFunction \ -e AEGS_topics__0__subscribers__http__1__disableValidation=true \ -e AEGS_Serilog__MinimumLevel__Default=Verbose \ pmcilreavy/azureeventgridsimulator:latest ``` -------------------------------- ### Service Bus Subscriber with Topic-Level Connection String Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Service-Bus-Subscribers Illustrates how a Service Bus subscriber can inherit its connection string from the topic-level configuration, simplifying setup when multiple subscribers share the same Service Bus endpoint. ```json { "topics": [ { "name": "OrdersTopic", "port": 60101, "serviceBusConnectionString": "Endpoint=sb://my-namespace.servicebus.windows.net/;...", "subscribers": { "serviceBus": [ { "name": "OrdersQueue", "queue": "orders-queue" } ] } } ] } ``` -------------------------------- ### Build the Project Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Contributing Build the entire project using the .NET CLI. ```bash dotnet build ``` -------------------------------- ### Build Project Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/AGENTS.md Builds the Azure Event Grid Simulator solution in Release configuration. ```bash # Build dotnet build src/AzureEventGridSimulator.sln --configuration Release ``` -------------------------------- ### Run the Simulator Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Contributing Navigate to the application's source directory and run the simulator using the .NET CLI. ```bash cd src/AzureEventGridSimulator dotnet run ``` -------------------------------- ### Run Simulator with Custom Configuration File Source: https://github.com/pm7y/azureeventgridsimulator/wiki/DotNet-Tool Specify a custom JSON configuration file for the simulator using the --ConfigFile argument. ```bash azure-eventgrid-simulator --ConfigFile=/path/to/my-config.json ``` -------------------------------- ### Specify Configuration File via Command Line Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Configuration How to point the Azure Event Grid Simulator executable to a specific configuration file using the `--ConfigFile` argument. ```bash AzureEventGridSimulator.exe --ConfigFile=/path/to/config.json ``` -------------------------------- ### Create Simulator Configuration File Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Defines topics, ports, keys, and subscribers for the Event Grid Simulator. This JSON file is mounted into the Docker container. ```json { "topics": [ { "name": "my-topic", "port": 60101, "key": "TheLocal+DevelopmentKey=", "subscribers": { "http": [ { "name": "webhook-subscriber", "endpoint": "https://webhook.site/your-unique-id", "disableValidation": true } ] } } ] } ``` -------------------------------- ### Generate and Trust Development Certificate Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Generates a self-signed HTTPS development certificate and trusts it for local development. This is a one-time setup step. ```bash dotnet dev-certs https --trust ``` ```bash dotnet dev-certs https \ --export-path ./certs/eventgrid.pfx \ --password password123 ``` -------------------------------- ### System Context Diagram Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Architecture Illustrates the overall system context, showing how the simulator interacts with publishers, developers, and various Azure services. ```mermaid flowchart LR Publisher["Event Publisher"] Developer["Developer"] subgraph Simulator["Azure Event Grid Simulator"] API["POST /api/events"] Dashboard["Dashboard UI"] end HTTP["HTTP Webhook"] SB["Azure Service Bus"] SQ["Azure Storage Queue"] EH["Azure Event Hub"] Publisher -->|HTTPS| API API -->|HTTP/HTTPS| HTTP API -->|AMQP| SB API -->|HTTPS| SQ API -->|AMQP| EH Developer -->|HTTPS| Dashboard ``` -------------------------------- ### Advanced Filtering Configuration Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Example JSON structure for configuring advanced filters on an event subscription. Supports complex conditions on event data. ```json { "filter": { "advancedFilters": [ { "operatorType": "NumberGreaterThan", "key": "data.orderTotal", "value": 100 }, { "operatorType": "StringIn", "key": "data.region", "values": ["us-east", "us-west", "eu-west"] }, { "operatorType": "IsNotNull", "key": "data.customerId" } ] } } ``` -------------------------------- ### Topic and Subscriber Configuration via Environment Variables Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Configuration Use double underscores to represent nested JSON paths for topic and subscriber configuration. This format is essential for setting up the simulator's behavior. ```bash # Topic configuration AEGS_topics__0__name=MyTopic AEGS_topics__0__port=60101 AEGS_topics__0__key=TheLocal+DevelopmentKey= # Subscriber configuration AEGS_topics__0__subscribers__http__0__name=MySubscriber AEGS_topics__0__subscribers__http__0__endpoint=http://localhost:7071/api/MyFunction AEGS_topics__0__subscribers__http__0__disableValidation=true # App settings AEGS_dashboardEnabled=true AEGS_dashboardPort=9000 ``` -------------------------------- ### Minimal Docker Compose for Azure Event Grid Simulator using Environment Variables Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md This configuration demonstrates setting up the Azure Event Grid Simulator with minimal environment variables, avoiding the need for separate configuration files. It directly configures topics, ports, keys, and subscribers via environment variables. ```yaml services: eventgrid: image: pmcilreavy/azureeventgridsimulator:latest ports: - "60101:60101" volumes: - ./certs:/certs:ro environment: # Certificate - ASPNETCORE_Kestrel__Certificates__Default__Path=/certs/eventgrid.pfx - ASPNETCORE_Kestrel__Certificates__Default__Password=password123 # Topic configuration - AEGS_Topics__0__name=my-topic - AEGS_Topics__0__port=60101 - AEGS_Topics__0__key=MyTopicKey= # HTTP subscriber - AEGS_Topics__0__subscribers__http__0__name=webhook - AEGS_Topics__0__subscribers__http__0__endpoint=https://webhook.site/your-id - AEGS_Topics__0__subscribers__http__0__disableValidation=true ``` -------------------------------- ### Run Application Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/AGENTS.md Runs the Azure Event Grid Simulator application. ```bash # Run dotnet run --project src/AzureEventGridSimulator/AzureEventGridSimulator.csproj ``` -------------------------------- ### Clone the Repository Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Contributing Clone the Azure Event Grid Simulator project from GitHub and navigate into the project directory. ```bash git clone https://github.com/pm7y/AzureEventGridSimulator.git cd AzureEventGridSimulator ``` -------------------------------- ### Building with Warnings as Errors Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Contributing Build the project and treat all warnings as errors to ensure code quality. ```bash dotnet build --warnaserror ``` -------------------------------- ### Configure Endpoints in AppHost Program.cs Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Aspire Customize topic ports for the simulator within the Aspire AppHost's Program.cs file using WithHttpsEndpoint. ```csharp // In AppHost Program.cs builder.AddProject("eventgridsimulator") .WithHttpsEndpoint(name: "topic1", port: 60101, isProxied: false) .WithHttpsEndpoint(name: "topic2", port: 60102, isProxied: false); ``` -------------------------------- ### Configure Simulator via Environment Variables Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Runs the simulator container using environment variables to define topic properties, including name, port, key, and subscriber endpoint. Nested properties are separated by double underscores. ```bash docker run -d \ -e AEGS_Topics__0__name=my-topic \ -e AEGS_Topics__0__port=60101 \ -e AEGS_Topics__0__key=MySecretKey= \ -e AEGS_Topics__0__subscribers__http__0__name=webhook \ -e AEGS_Topics__0__subscribers__http__0__endpoint=https://example.com/webhook \ -e AEGS_Topics__0__subscribers__http__0__disableValidation=true \ pmcilreavy/azureeventgridsimulator:latest ``` -------------------------------- ### Trust .NET Development Certificate Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Topics Ensure the .NET development certificate is installed and trusted for HTTPS connections. This is a prerequisite for the simulator to use the certificate to secure topic ports. ```bash dotnet dev-certs https --trust ``` -------------------------------- ### Run Unit Tests Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/AGENTS.md Executes all unit tests for the Azure Event Grid Simulator solution in Release configuration. ```bash # Test dotnet test src/AzureEventGridSimulator.sln --configuration Release dotnet test src/AzureEventGridSimulator.sln --filter "Category=unit" ``` -------------------------------- ### Run Integration Tests Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/AGENTS.md Executes integration tests for the Azure Event Grid Simulator solution in Release configuration. ```bash dotnet test src/AzureEventGridSimulator.sln --filter "Category=integration" ``` -------------------------------- ### CloudEvents Schema Data Payload (Batch Mode) Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Schema-Support An example of a JSON array containing multiple CloudEvents, suitable for sending in batch mode. Each object in the array represents a distinct CloudEvent. ```json [ { "specversion": "1.0", "type": "com.example.event1", "source": "/mycontext", "id": "event-1", "data": { "message": "First event" } }, { "specversion": "1.0", "type": "com.example.event2", "source": "/mycontext", "id": "event-2", "data": { "message": "Second event" } } ] ``` -------------------------------- ### Event Grid Schema Data Payload Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Schema-Support This is an example JSON payload for the Azure Event Grid schema. It includes essential fields like id, subject, eventType, eventTime, and data. ```json [ { "id": "8727823", "subject": "/example/subject", "data": { "MyProperty": "This is my awesome data!" }, "eventType": "Example.DataType", "eventTime": "2019-01-01T00:00:00.000Z", "dataVersion": "1" } ] ``` -------------------------------- ### Running Simulator with Custom Certificate Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Docker command to run the simulator using a custom PFX certificate. Mounts a volume for certificates and sets environment variables for the certificate path and password. ```bash docker run -d \ -v /path/to/certs:/certs:ro \ -e ASPNETCORE_Kestrel__Certificates__Default__Path=/certs/mycert.pfx \ -e ASPNETCORE_Kestrel__Certificates__Default__Password=certpassword \ pmcilreavy/azureeventgridsimulator:latest ``` -------------------------------- ### CloudEvents Schema Data Payload (Structured Mode) Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Schema-Support An example of a single CloudEvent formatted for structured mode. It includes standard CloudEvents attributes like specversion, type, source, id, and time. ```json { "specversion": "1.0", "type": "com.example.someevent", "source": "/mycontext/subcontext", "id": "A234-1234-1234", "time": "2025-01-15T10:30:00Z", "subject": "/example/subject", "datacontenttype": "application/json", "data": { "MyProperty": "This is my awesome data!" } } ``` -------------------------------- ### Configure Azure Event Grid Simulator Topics and Subscribers Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/README.md Defines the topics, ports, keys, and subscribers for the simulator in an appsettings.json file. This configuration is essential for setting up your simulation environment. ```json { "topics": [ { "name": "MyTopic", "port": 60101, "key": "TheLocal+DevelopmentKey=", "subscribers": { "http": [ { "name": "MySubscriber", "endpoint": "http://localhost:7071/api/MyFunction", "disableValidation": true } ] } } ] } ``` -------------------------------- ### Running Unit Tests Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Contributing Execute all unit tests for the project using the dotnet test command. ```bash dotnet test ``` -------------------------------- ### Run All Tests Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Contributing Execute all tests within the project. ```bash dotnet test src/AzureEventGridSimulator.sln ``` -------------------------------- ### Manual Code Formatting Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Contributing Restore CSharpier tools and format the source code manually. ```bash dotnet tool restore dotnet csharpier format src ``` -------------------------------- ### Post Events to Azure Event Grid Simulator Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/README.md Sends a POST request with sample events to the simulator's topic endpoint. Ensure the API version and SAS key match your configuration. ```bash curl -k -X POST "https://localhost:60101/api/events?api-version=2018-01-01" \ -H "Content-Type: application/json" \ -H "aeg-sas-key: TheLocal+DevelopmentKey=" \ -d '[{"id":"1","subject":"/test","eventType":"Test","eventTime":"2024-01-01T00:00:00Z","data":{"message":"Hello"},"dataVersion":"1"}]' ``` -------------------------------- ### Docker Compose for Azure Event Grid Simulator with Full Configuration Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md This configuration sets up the Azure Event Grid Simulator along with its dependencies like Seq, Azurite, and Service Bus emulator. It maps ports, mounts volumes, and defines environment variables for each service, including certificate paths and configuration file locations. ```yaml services: eventgrid: image: pmcilreavy/azureeventgridsimulator:latest container_name: eventgrid ports: - "60101:60101" - "60102:60102" volumes: - ./docker:/aegs:ro environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_Kestrel__Certificates__Default__Path=/aegs/azureEventGridSimulator.pfx - ASPNETCORE_Kestrel__Certificates__Default__Password=Y0urSup3rCrypt1cPa55w0rd! - TZ=UTC - AEGS_ConfigFile=/aegs/appsettings.json - AEGS_dangerousAcceptAnyServerCertificateValidator=true depends_on: - seq - azurite - servicebus-emulator seq: image: datalust/seq:latest container_name: seq ports: - "8081:80" - "5341:5341" environment: - ACCEPT_EULA=Y azurite: image: mcr.microsoft.com/azure-storage/azurite:latest container_name: azurite ports: - "10000:10000" # Blob - "10001:10001" # Queue - "10002:10002" # Table command: "azurite --blobHost 0.0.0.0 --queueHost 0.0.0.0 --tableHost 0.0.0.0" mssql: image: mcr.microsoft.com/mssql/server:2022-latest container_name: mssql environment: - ACCEPT_EULA=Y - MSSQL_SA_PASSWORD=YourStrong@Passw0rd! servicebus-emulator: image: mcr.microsoft.com/azure-messaging/servicebus-emulator:latest container_name: servicebus-emulator ports: - "5672:5672" volumes: - ./docker/servicebus-config.json:/ServiceBus_Emulator/ConfigFiles/Config.json:ro environment: - ACCEPT_EULA=Y - MSSQL_SA_PASSWORD=YourStrong@Passw0rd! - SQL_SERVER=mssql depends_on: - mssql ``` -------------------------------- ### Run Unit Tests Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Contributing Execute unit tests for the project, filtering by the 'unit' category. ```bash dotnet test src/AzureEventGridSimulator.sln --filter "Category=unit" ``` -------------------------------- ### Format Code Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/AGENTS.md Formats the C# code in the source directory using CSharpier. This runs automatically on build. ```bash # Format (runs automatically on build) dotnet csharpier format src ``` -------------------------------- ### Storage Queue Subscriber with Topic-Level Connection String Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Storage-Queue-Subscribers Demonstrates configuring a Storage Queue subscriber that inherits its connection string from the topic level. ```json { "topics": [ { "name": "OrdersTopic", "port": 60101, "storageQueueConnectionString": "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=...;EndpointSuffix=core.windows.net", "subscribers": { "storageQueue": [ { "name": "OrdersArchive", "queueName": "orders-archive" } ] } } ] } ``` -------------------------------- ### Accepting Self-Signed Certificates Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Environment variable to enable the simulator to accept any server certificate. Use only in development environments. ```bash -e AEGS_dangerousAcceptAnyServerCertificateValidator=true ``` -------------------------------- ### Configure Simulator with Environment Variables Source: https://github.com/pm7y/azureeventgridsimulator/wiki/DotNet-Tool Set environment variables with the AEGS_ prefix to configure the simulator. Hierarchy is separated by double underscores (__). ```bash export AEGS_topics__0__name=MyTopic export AEGS_topics__0__port=60101 export AEGS_topics__0__key="TheLocal+DevelopmentKey=" export AEGS_topics__0__subscribers__http__0__name=MySubscriber export AEGS_topics__0__subscribers__http__0__endpoint=http://localhost:7071/api/events export AEGS_topics__0__subscribers__http__0__disableValidation=true azure-eventgrid-simulator ``` -------------------------------- ### Docker Deployment Configuration Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Configuration Deploy the simulator using Docker, mapping ports and setting environment variables for configuration. Note the use of 'host.docker.internal' for the subscriber endpoint when running in Docker. ```bash docker run -p 60101:60101 \ -e AEGS_topics__0__name=MyTopic \ -e AEGS_topics__0__port=60101 \ -e AEGS_topics__0__key=TheLocal+DevelopmentKey= \ -e AEGS_topics__0__subscribers__http__0__name=MySubscriber \ -e AEGS_topics__0__subscribers__http__0__endpoint=http://host.docker.internal:7071/api/MyFunction \ pmcilreavy/azureeventgridsimulator ``` -------------------------------- ### Seq Logging Configuration Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md JSON configuration for integrating the simulator with Seq for structured logging. ```json { "Serilog": { "MinimumLevel": { "Default": "Information" }, "WriteTo": [ { "Name": "Console" }, { "Name": "Seq", "Args": { "serverUrl": "http://seq:5341" } } ] } } ``` -------------------------------- ### Enable Verbose Logging with Serilog Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Troubleshooting Configure Serilog in appsettings.json to enable debug-level logging and write to the console. ```json { "Serilog": { "MinimumLevel": { "Default": "Debug" }, "WriteTo": [ { "Name": "Console" } ] } } ``` -------------------------------- ### Formatting Code with CSharpier Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Contributing Format the source code using CSharpier to maintain consistent code style. ```bash dotnet csharpier format src ``` -------------------------------- ### Restore Dependencies Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Contributing Restore project dependencies using the .NET CLI. ```bash dotnet restore ``` -------------------------------- ### Source Code Structure Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Architecture Overview of the project's directory structure, detailing the organization of controllers, domain services, infrastructure components, and the application entry point. ```text src/AzureEventGridSimulator/ ├── Controllers/ # HTTP endpoints ├── Dashboard/ # Embedded dashboard UI assets ├── Domain/ │ ├── Commands/ # Command handlers (mediator pattern) │ ├── Entities/ # Domain models (SimulatorEvent, PendingDelivery) │ │ └── Dashboard/ # Dashboard-specific entities │ └── Services/ │ ├── Dashboard/ # Event history tracking for dashboard │ ├── Delivery/ # Subscriber-specific delivery services │ ├── Retry/ # Retry scheduling, queue, dead-letter │ ├── Routing/ # Event routing logic │ └── Validation/ # Schema detection, parsing, formatting ├── Infrastructure/ │ ├── Dashboard/ # Dashboard middleware and endpoints │ ├── Extensions/ # Filtering logic │ ├── JsonConverters/ # Custom JSON serialization │ ├── Mediator/ # Custom mediator implementation │ ├── Middleware/ # Request validation and parsing │ └── Settings/ # Configuration models │ └── Subscribers/ # Subscriber-specific settings └── Program.cs # Application entry point ``` -------------------------------- ### Run Docker Compose Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Docker Builds and detaches Docker containers defined in the docker-compose.yml file, including the simulator and various Azure emulators for local development. ```bash cd docker docker-compose up --build --detach ``` -------------------------------- ### Send Test Event to Simulator Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Uses curl to send a sample event to the running simulator. It includes necessary headers for content type and SAS key, and a JSON payload representing an order creation event. ```bash curl -k \ -H "Content-Type: application/json" \ -H "aeg-sas-key: TheLocal+DevelopmentKey=" \ -X POST "https://localhost:60101/api/events?api-version=2018-01-01" \ -d '[{ "id": "test-event-1", "subject": "/orders/12345", "eventType": "Order.Created", "eventTime": "2025-01-15T10:00:00Z", "data": { "orderId": "12345", "customerId": "cust-789", "total": 99.99 }, "dataVersion": "1.0" }]' ``` -------------------------------- ### Exporting .NET Development Certificate for Docker Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Command to export the .NET development HTTPS certificate to a PFX file for use with Docker. Requires a secure password. ```bash dotnet dev-certs https \ --export-path ./certs/eventgrid.pfx \ --password YourSecurePassword123 ``` -------------------------------- ### Event Hubs Simulator Configuration Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Event-Hub-Subscribers Defines the structure for topics, including their connection details, event hub names, delivery schemas, filters, and dynamic property mappings. ```json { "topics": [ { "name": "OrdersTopic", "port": 60101, "key": "TheLocal+DevelopmentKey=", "eventHubConnectionString": "Endpoint=sb://my-eventhub-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=...", "subscribers": { "eventHub": [ { "name": "OrdersEventHubSubscription", "eventHubName": "orders-events", "deliverySchema": "CloudEventV1_0", "filter": { "includedEventTypes": ["Order.Created"] }, "properties": { "OrderId": { "type": "dynamic", "value": "data.orderId" }, "Region": { "type": "static", "value": "west-us" } } } ] } } ] } ``` -------------------------------- ### Send Event with EventGridPublisherClient Source: https://github.com/pm7y/azureeventgridsimulator/wiki/Schema-Support Use the EventGridPublisherClient to send events to the simulator. Ensure you have the correct endpoint and a valid development key. ```csharp var client = new EventGridPublisherClient( new Uri("https://localhost:60101/api/events"), new AzureKeyCredential("TheLocal+DevelopmentKey=")); await client.SendEventAsync(new EventGridEvent( subject: "/example/subject", eventType: "Example.EventType", dataVersion: "1.0", data: new { Message = "Hello" })); ``` -------------------------------- ### Appsettings JSON Configuration for Event Grid Simulator Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md This JSON file configures the Azure Event Grid Simulator, defining topics, ports, keys, and subscribers for HTTP, Service Bus, and Storage Queue. It specifies endpoints, connection strings, and filters for message routing. ```json { "Serilog": { "MinimumLevel": { "Default": "Information" }, "WriteTo": [ { "Name": "Console" }, { "Name": "Seq", "Args": { "serverUrl": "http://seq:5341" } } ] }, "topics": [ { "name": "orders-topic", "port": 60101, "key": "OrdersTopicKey=", "subscribers": { "http": [ { "name": "order-webhook", "endpoint": "https://webhook.site/your-unique-id", "disableValidation": true, "filter": { "includedEventTypes": ["Order.Created"] } } ], "serviceBus": [ { "name": "order-queue", "connectionString": "Endpoint=sb://servicebus-emulator;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;", "queue": "orders", "properties": { "OrderId": { "type": "dynamic", "value": "data.orderId" } } } ], "storageQueue": [ { "name": "order-audit", "connectionString": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;QueueEndpoint=http://azurite:10001/devstoreaccount1;", "queueName": "order-audit" } ] } }, { "name": "notifications-topic", "port": 60102, "key": "NotificationsKey=", "subscribers": { "http": [ { "name": "notification-handler", "endpoint": "https://myapp.local/notifications", "disableValidation": true } ] } } ] } ``` -------------------------------- ### Subscriber Configuration Format Source: https://github.com/pm7y/azureeventgridsimulator/blob/master/docker/README.md Illustrates the JSON structure for defining different types of subscribers (HTTP, Service Bus, Storage Queue) within the simulator's configuration. ```json { "subscribers": { "http": [ /* HTTP webhook subscribers */ ], "serviceBus": [ /* Service Bus queue/topic subscribers */ ], "storageQueue": [ /* Storage Queue subscribers */ ] } } ```