mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
How to deploy WireMock in Azure ? #327
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 @waqaskhan540 on GitHub (Jan 22, 2021).
Originally assigned to: @StefH on GitHub.
I have deployed WebApplication example of WireMock using Azure App Service , but I am not sure what should be the URL and Port of server , because ports 443 and 80 are already being used by the application itself and I am not sure what URL I can run the wiremock server on within the Hosted Service?
Could you please provide a tutorial on how to deploy WireMock in Azure or is there a better way to deploy it in Azure?
@StefH commented on GitHub (Jan 22, 2021):
The link to the example app in the wiki page was wrong. I did correct this. See https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.WebApplication.NETCore3
When you run WireMock.Net as an WebApp in Azure it should just listen at 80 and 433
@waqaskhan540 commented on GitHub (Jan 22, 2021):
Yes that's correct, but I am not able to get it working, I deployed first with the same configuration settings but got no response.
I am deploying directly from Visual Studio using the publish wizard to Azure App Service, the WebApp is deployed at say following URl https://wiremockwebapp2211.azurewebsites.com , but it gives the following error in browser
HTTP Error 500.37 - ANCM Failed to Start Within Startup Time Limit
Common solutions to this issue:
ANCM failed to start after 120000 milliseconds
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft.com/fwlink/?LinkID=2028265
I tried with following settings even, but got same response
@StefH commented on GitHub (Jan 22, 2021):
I just built that example project and published to Azure, and it works fine.

Settings are:

@waqaskhan540 commented on GitHub (Jan 25, 2021):
Thanks, its working now.
@StefH commented on GitHub (Jan 25, 2021):
OK
@davemasters1984 commented on GitHub (Apr 4, 2022):
I am really struggling to get this working. I want to achieve the same as your screenshot - WireMock responding to URLs hosted in an Azure Web App with SSL.
I have copied the sample from here and tried various configurations:
1) With SSL
Which fails to start the app and produces this error:
Unhandled exception. WireMock.Exceptions.WireMockException: Service start failed with error: One or more errors occurred. (Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found or is out of date.2) Without SSL
Which again fails to start the app, but this time with the error:
Unhandled exception. WireMock.Exceptions.WireMockException: Service start failed with error: One or more errors occurred. (An attempt was made to access a socket in a way forbidden by its access permissions.)This time the app doesn't fail to start, but the response returns a 404, but not from WireMock. Presumably this is because WireMock itself is not listening on port 80. I'm lead to believe this because when I run this locally with this configuration, I can see WireMock chooses a random port by writing this to the console:
What am I missing in order to get Wiremock to listen on the same port as the Azure Web App and use SSL?
@davemasters1984 commented on GitHub (Apr 14, 2022):
I noticed you've re-opened this, which I'm grateful for. Don't suppose you have any insights on where I'm going wrong?
@davemasters1984 commented on GitHub (Apr 22, 2022):
@waqaskhan540 I don't suppose you could share what you changed to get it working? As far as I can tell I have exactly the same as the sample application apart from I'm running dotnet 6 not dotnet core 3.1
@waqaskhan540 commented on GitHub (Apr 22, 2022):
@davemasters1984 it was a while ago I was working with WireMock, but as far as I remember I didn't change anything, I just published the sample and worked fine for me.
@davemasters1984 commented on GitHub (Apr 22, 2022):
Thanks for replying! Do you remember whether you specified 80/443 in the config? The sample app doesn't have any port config, but for me this just causes Wiremock to listen on a random port, but specifying 80 in config gives the error: "An attempt was made to access a socket in a way forbidden by its access permissions"
It's driving me nuts 😭
@StefH commented on GitHub (Apr 28, 2022):
Hello @davemasters1984,
I did use the https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.WebApplication.NETCore3 as an example.
And I published this application via VS 2022 via right click to a Windows App Service plan.

And it runs fine at https://wiremocknetwebapplicationnetcore3.azurewebsites.net/
In Azure there are no specific config settings:

The deployed
web.configlooks like:And more information why this all works fine, see this post https://weblog.west-wind.com/posts/2016/Jun/06/Publishing-and-Running-ASPNET-Core-Applications-with-IIS which describes in detail how port 80/443 can be used on IIS/Azure when using a .NET Core application.
@StefH commented on GitHub (Jun 9, 2022):
Hello @davemasters1984, did you manage to get it running on Azure using the above details?
@StefH commented on GitHub (Aug 25, 2022):
Hello @davemasters1984, did you manage to get it running on Azure using the above details?
@Elangopalakrishnan commented on GitHub (Aug 25, 2022):
@StefH @waqaskhan540 @davemasters1984 Thanks for sharing knowledge in this thread,
I have followed the same https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.WebApplication.NETCore3
My launch settings JSON same as an above sample project,
My web. config same as an above sample project.
I deployed on Azure and tried hitting the endpoint but it's getting timed out,.
Then I tried to set up _a setting like below
But I got an error "HTTP Error 500.30 - ANCM In-Process Start Failure"
Could you please share your thoughts...
Thanks,
Elango
@StefH commented on GitHub (Sep 19, 2022):
@Elangopalakrishnan
What kind of App Service Plan are you using?
BTW: I'm using a
S1: 1-Windowsplan.@mattisking commented on GitHub (Sep 20, 2022):
Try not setting the ports in the config. That’s what worked for us.
@Elangopalakrishnan commented on GitHub (Sep 22, 2022):
@StefH
Thanks for replying!
I've created an Azure web app with S1: 1 - Windows app service plan,
I deployed the web app and got startup error
I didn't create any custom domain and TSL/SSL certs in Azure. (doubt that this is causing the issue)
And I'm getting below error only on Azure
Could you pls have a look 🥲? Thanks!
@adeel41 commented on GitHub (Sep 23, 2022):
I am glad that I have solved this for myself. I am using a B1 App service plan with Linux. Not sure if this will be relevent to the solution but just fyi.
It was quite simple to fix. I just had to use port
8080for WireMockServerSettings Port setting. No SSL or any urls to set.I've found this by looking at the docker container logs which you can find in App Service
Advanced Tools. You can download theCurrent Docker logs.This is a sample of what is in the log and how I've found this.
So if you have a look at the docker run command, it is running the container and binding with these ports. And at the bottom, it is complaining that it cannot ping on port 8080 because nothing is listening on that port.
btw, the site would be still accesable on https since this is set on the the App Service and then it just forwards the requests to the running instance of your app in docker.
@Elangopalakrishnan commented on GitHub (Sep 25, 2022):
@adeel41 Thank you for reply!
Yes, It got worked for me as well 😇
I'm using the B1: Windows app service plan.
Thank you for your guidance @StefH @adeel41 and @mattisking 😊
@kamilb-pg commented on GitHub (Oct 25, 2022):
Hi,
Sorry to open this again, the .net core example is working for me but since it's reaching end of support I wanted to upgrade to .NET 6.
I set the port to 8080 but am getting
Unhandled exception. System.IO.IOException: Failed to bind to address http://[::]:8080: address already in use.This is a Linux app service and B1 plan.
Thanks
@StefH commented on GitHub (Oct 25, 2022):
@kamilb-pg
I think the settings should be like:
I've updated example project here:
https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.WebApplication.NET6
And added some images to the wiki
https://github.com/WireMock-Net/WireMock.Net/wiki/WireMock-as-a-(Azure)-Web-App
@shilpamurthy88 commented on GitHub (Mar 14, 2023):
Hi,
Deploying the https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.WebApplication.NET6 as is in azure, I am still getting the below error
HTTP Error 500.37 - ASP.NET Core app failed to start within startup time limit
Common solutions to this issue:
ASP.NET Core app failed to start after 120000 milliseconds
Troubleshooting steps:
Check the system event log for error messages
Enable logging the application process' stdout messages
Attach a debugger to the application process and inspect
For more information visit: https://go.microsoft.com/fwlink/?LinkID=2028265
Using app service plan S1.
Any help is appreciated.
@priyankas0907 commented on GitHub (May 16, 2023):
I am not able to run wiremock with same port as my web app on IIS. Please elaborate a bit on the solution