mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-24 18:11:10 +01:00
Created WireMock as a (Azure) Web-App (markdown)
44
WireMock-as-a-(Azure)-Web-App.md
Normal file
44
WireMock-as-a-(Azure)-Web-App.md
Normal file
@@ -0,0 +1,44 @@
|
||||
It's also possible to run WireMock as a Web-Application on Azure.
|
||||
|
||||
# WireMockService
|
||||
See this code example how a App-Service could look:
|
||||
|
||||
``` csharp
|
||||
public class WireMockService : IWireMockService
|
||||
{
|
||||
private static int sleepTime = 30000;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IFluentMockServerSettings _settings;
|
||||
|
||||
private class Logger : IWireMockLogger
|
||||
{
|
||||
// Implement all methods from the IWireMockLogger here ...
|
||||
}
|
||||
|
||||
public WireMockService(ILogger logger, IFluentMockServerSettings settings)
|
||||
{
|
||||
_logger = logger;
|
||||
_settings = settings;
|
||||
|
||||
_settings.Logger = new Logger(logger);
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
_logger.LogInformation("WireMock.Net server starting");
|
||||
|
||||
StandAloneApp.Start(_settings);
|
||||
|
||||
_logger.LogInformation($"WireMock.Net server settings {JsonConvert.SerializeObject(_settings)}");
|
||||
|
||||
while (true)
|
||||
{
|
||||
_logger.LogInformation("WireMock.Net server running");
|
||||
Thread.Sleep(sleepTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#Example
|
||||
For a full working example, see [examples\WireMock.Net.WebApplication](https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.WebApplication)
|
||||
Reference in New Issue
Block a user