mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Feature: Mapping files lost when restarting an Azure app service #121
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @craigt00 on GitHub (Aug 7, 2018).
Originally assigned to: @StefH on GitHub.
I've found that when hosting WireMock.Net in an Azure app service the mappings are lost when the app service restarts. I presume this is due to the resolved location of Directory.GetCurrentDirectory() when running in Azure which may be getting cleaned out during a restart.
If this is the case, could I suggest that the base directory is injected in (via IFluentMockServerSettings?) and, if set, used instead of GetCurrentDirectory()? This can then be specifically set for the example projects which need to control the location of their files such as WireMock.Net.WebApplication.NETCore2.
As an alternative, the files could be stored within Azure File or Blob storage (again, via dependancy injecting in a new class to handle file system activity).
@StefH commented on GitHub (Aug 7, 2018):
Good point. The same issue will probably be the case for a docker image.
The best solution would be via dependency injection / new classes to handle file system activity.
Example:
Or hide more to the user, so only this interface remains:
Where by default these classes will handle the local file-system.
@StefH commented on GitHub (Aug 13, 2018):
@craigt00
I've implemented this change into this branch:
https://github.com/WireMock-Net/WireMock.Net/blob/stef_issue_173_mappingfiles_location/src/WireMock.Net/Handlers/IFileSystemHandler.cs
Can you please review ? If it's good enough, I'll merge to master.
@craigt00 commented on GitHub (Aug 14, 2018):
That looks great, and will allow me to create a azure-specific implementation. Thanks for working on this @StefH
Is the web application example intended to be Azure-specific? If so then I'll fork and update the web application to implement an AzureFileSystemHandler which places the mapping files alongside the site.
@StefH commented on GitHub (Aug 14, 2018):
The web-application can run as standalone, web-IIS or Azure.
So for your idea, maybe best to create a new example project called WireMock.Net.Azure.NETCore2 which implements that
AzureFileSystemHandler.Or update the original example to use a switch in the configuration to choose the FileHandler.
I'll create a PR merge tho master in some time today.
@StefH commented on GitHub (Aug 14, 2018):
Linked https://github.com/WireMock-Net/WireMock.Net/pull/180