-
-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Mapping files lost when restarting an Azure app service #173
Comments
Good point. The same issue will probably be the case for a docker image. Example: interface IDirectoryHandler
{
string GetCurrent();
bool Exists(string path);
}
interface IFileHandler
{
string ReadAllText(string path);
void WriteAllText(string text);
} Or hide more to the user, so only this interface remains: interface IStaticMappingHandler
{
/// <summary>
/// Reads a static mapping by the specified filename.
/// </summary>
/// <param name="filename">The mapping filename.</param>
/// <param name="folder">The optional folder (when not defined, use `__admin/mappings`).</param>
/// <returns>Mapping as text</returns>
string Read(string filename, string folder = null);
/// <summary>
/// Writes the mapping to specified filename.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="filename">The mapping filename.</param>
/// <param name="folder">The optional folder (when not defined, use `__admin/mappings`).</param>
/// <returns>true in case saving was successful, else false.</returns>
bool Write(string text, string filename, string folder = null);
} Where by default these classes will handle the local file-system. |
I've implemented this change into this branch: Can you please review ? If it's good enough, I'll merge to master. |
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. |
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 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. |
Linked #180 |
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).
The text was updated successfully, but these errors were encountered: