Azure EventGrid Simulator is a sample app purpose is to run on local for Dev and test for non production use only.
$ dotnet add package Hasulab.Azure.EventGrid.SimulatorAzureEventGridSimulator Sample proejct
builder.Services.AddLogging();
builder.Services.AddSimulatorServices(builder.Configuration);
//Other codes
app.MapSimulatorEndpoint();
"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" ]
}
}
}
]
$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]
* 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.
* 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.
$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
* 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.
* 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)