Hasulab.Azure.EventGrid.Simulator 0.8.0

dotnet add package Hasulab.Azure.EventGrid.Simulator --version 0.8.0                
NuGet\Install-Package Hasulab.Azure.EventGrid.Simulator -Version 0.8.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Hasulab.Azure.EventGrid.Simulator" Version="0.8.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hasulab.Azure.EventGrid.Simulator --version 0.8.0                
#r "nuget: Hasulab.Azure.EventGrid.Simulator, 0.8.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Hasulab.Azure.EventGrid.Simulator as a Cake Addin
#addin nuget:?package=Hasulab.Azure.EventGrid.Simulator&version=0.8.0

// Install Hasulab.Azure.EventGrid.Simulator as a Cake Tool
#tool nuget:?package=Hasulab.Azure.EventGrid.Simulator&version=0.8.0                

azure-eventgrid-simulator

AzureEventGridSimulator Sample proejct

Getting Started

builder.Services.AddLogging();
builder.Services.AddSimulatorServices(builder.Configuration);
//Other codes
app.MapSimulatorEndpoint();

  • Add following sample Kestrel settings to appsettings.json or appsettings.Development.json
  "Kestrel": {
    "Certificates": {
      "Default": {
        "Path": "localhost-TestPASS1234.pfx",
        "Password": "TestPASS1234"
      }
    }
  },
  "EventDeliverySettings": {
    "CheckUpdateTime": 1000,
    "ConcurrentEventsProcessing": 2 
  }

and events subscriptions settings to appsettings.json or appsettings.Development.json

"topics": [
    {
      "name": "MyLocalAzureFunctionTopic",
      "port": 5002,
      "key": "TheLocal+DevelopmentKey=",
      "subscribers": [
        {
          "name": "LocalAzureFunctionSubscription",
          "destination": {
            "endpointType": "WebHook",
            "properties": {
              "endpoint": "http://localhost:7071/runtime/webhooks/EventGrid?functionName=ExampleFunction",
              "disableValidation": true
            }
          },
          "filter": {
            "includedEventTypes": [ "TestEvent" ]
          }
        }
    }
  ]
  • Press F5 or run the proejct

create local host certificate

Create a self-signed root certificate

$params = @{
    Type = 'Custom'
    Subject = 'CN=MyLocalhostRootCert'
    KeySpec = 'Signature'
    KeyExportPolicy = 'Exportable'
    KeyUsage = 'CertSign'
    KeyUsageProperty = 'Sign'
    KeyLength = 2048
    HashAlgorithm = 'sha256'
    NotAfter = (Get-Date).AddMonths(24)
    CertStoreLocation = 'Cert:\CurrentUser\My'
}
$cert = New-SelfSignedCertificate @params

or find root certificate by name

 $certs = Get-ChildItem -path Cert:\* -Recurse | where {$_.Subject �like '*MyLocalhostRootCert*'}

 $certs.Length
 $cert = $certs[0]

or by thumbprint

 $certs = Get-ChildItem -Path "Cert:\*<THUMBPRINT>" -Recurse

 $certs.Length
 $cert = $certs[0]
Export CA certificate
* goto `run` and type `certmgr.msc`
* goto `Manage user certificates -> Certificates - Current Users` 
* goto `Personal -> Certificates`
* Right click on the root cetificate and follow the Wizard and  export with private key.
Imoprt root certificate to tursted root
* goto `Manage user certificates -> Certificates - Current Users`
* goto `Trusted Root Certification Authorities -> Certificates`
* right click on import and follow the Wizard
* seelct `Trusted Root Certification Authorities` where necessary.

Generate a client certificate with localhost

$params = @{
       Type = 'Custom'
       Subject = 'CN=localhost'
       DnsName = 'localhost'
       KeySpec = 'Signature'
       KeyExportPolicy = 'Exportable'
       KeyLength = 2048
       HashAlgorithm = 'sha256'
       NotAfter = (Get-Date).AddMonths(18)
       CertStoreLocation = 'Cert:\CurrentUser\My'
       Signer = $cert
       TextExtension = @(
        '2.5.29.37={text}1.3.6.1.5.5.7.3.1')
   }
   New-SelfSignedCertificate @params
$params = @{
       Type = 'Custom'
       Subject = 'CN=myhost'
       DnsName = 'myhost'
       KeySpec = 'Signature'
       KeyExportPolicy = 'Exportable'
       KeyLength = 2048
       HashAlgorithm = 'sha256'
       NotAfter = (Get-Date).AddMonths(18)
       CertStoreLocation = 'Cert:\CurrentUser\My'
       Signer = $cert
       TextExtension = @(
        '2.5.29.37={text}1.3.6.1.5.5.7.3.1')
   }
   New-SelfSignedCertificate @params
Export client/dns certificate
* goto `run` and type `certmgr.msc`
* goto `Manage user certificates -> Certificates - Current Users` 
* goto `Personal -> Certificates`
* Right click on the client/dns cetificate and follow the Wizard and  export with private key.
* Save as `localhost.pfx` in the `src\Local.ReverseProxy` folder and update the password in the ``appSettings.json`` file.
More info
* How to Generate and export certificates for point-to-site using PowerShell](https://learn.microsoft.com/en-us/azure/vpn-gateway/vpn-gateway-certificates-point-to-site)
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.8.0 114 7/19/2024
0.0.2 342 12/4/2022
0.0.1 312 12/3/2022

upgraded to dotnet 8