This note is regarding how to install Prism CLI as a Windows service. Prism CLI has a mock command which takes an API document and creates a mock server from the API documentation. The mock server will run until the shell windows stay open. By installing Prism CLI as a Windows service, we can keep the service running in the background.
-
Install NSSM
> choco install nssm -y
.Net Activity library supports using W3C trace identifiers
public class Program
{
public static void Main(string[] args)
{
Activity.DefaultIdFormat = ActivityIdFormat.W3C; //need to apply this as soon as the application starts
CreateHostBuilder(args).Build().Run();
- Run the docker-compose file -
docker-compose up -d
- Elasticsearch url to write the logs - http://localhost:9200/
- Kibana - http://localhost:5601/app/home
public static class HealthCheckResponses | |
{ | |
public static Task WriteJsonResponse(HttpContext context, HealthReport report) | |
{ | |
context.Response.ContentType = "application/json; charset=utf-8"; | |
var options = new JsonWriterOptions { Indented = true }; | |
using var writer = new Utf8JsonWriter(context.Response.BodyWriter, options); |
//Add more than one inspector to an EndpointBehavior | |
public class CustomEndpointBehavior : IEndpointBehavior | |
{ | |
private readonly List<IClientMessageInspector> _messageInspectors; | |
public CustomEndpointBehavior(List<IClientMessageInspector> messageInspectors) | |
{ | |
_messageInspectors = messageInspectors ?? throw new ArgumentNullException(nameof(messageInspectors)); | |
} | |
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) | |
{ |
HTTP triggers let you use API keys to block unknown callers by requiring the key to be present on each request. When you create a function, you select the authorization level. By default, it's set to "Function", which requires a function-specific API key, but it can also be set to "Admin" to use a global "master" key, or "Anonymous" to indicate that no key is required. You can also change the authorization level through the function properties after creation.
Since we specified "Function" when we created this function, we will need to supply the key when we send the HTTP request. You can send it
as a query string parameter named code
, or as an HTTP header (preferred) named x-functions-key
.