Are there any special deployment requirements for a REST Service to Azure? - wcf

I have written a REST service with windows azure using the WCF Rest Service Templates.
Locally everything runs fine. However when I deploy to Azure then all my requests return 500 Server Error.
Are there any special deployment requirements for a REST Service to Azure ?
I don't see anything in my project that points to local.
I left everything in the web.config set to defaults.

You should remote desktop into the Azure instance and check the Application Log. See this post on how to connect to the remote server instance. Most likely you are missing an assembly reference.

Related

Azure App Services cannot connect to Azure SQL Database

I have an API published to Azure App Services, using ef core, connect to Azure SQL database. below are the steps and the problem:
The Azure SQL database is up and running OK, I setup two firewall rules, one for my local dev ip, one for Azure App. I can connect to Azure SQL from local without any issue, and I have done the migrations.
I copied the connection string from Azure SQL and put in the appsettings.json, running the API from my local and connect to Azure SQL without any issue.
I published my API to Azure App services without any issues, I can see my app running OK since it has static file.
Then I went to Azure App Services => Settings/Configuration => Connection strings, create one new connect string with the same key/value as I used in the appsettings.json, based on the document from Microsoft: https://learn.microsoft.com/en-us/azure/app-service/containers/configure-language-dotnetcore#access-environment-variables
But the problem is after I done these, my API still not working, the api call to SQL return error 500.
Anything I missed or did wrong?
Thanks!
Thanks for the comments CSharpRocks, I did by adding the client ip, but I figured that's not the right way, so resolved by set the "Allow Azure services and resources to access this server" to True, that works.
For Others looking for the answer I had followed the steps above and it still did not work for me. But when I went to Visual Studios --> Publish --> Service Dependency's --> Add Azure SQL Database That fixed it for me.

How publish ASP.NET Core to a server without stop iis (error : The process cannot access the file because it is being used by another process)

When we publish our ASP.NET Core application and upload to the server, we get an error:
The process cannot access the file because it is being used by another process.
And when stop iis not error. How to upload without stopping IIS?
If you use web deploy to push to an IIS you own (a machine located in your datacenter) you can try to recycle the AppPool used by the web application you are trying to redeploy.
Go to your IIS Management Console
Right click the AppPool in question
Choose the recycle option
Be aware that this would also 'restart' all other apps which are associated to this AppPool.
This 'should' work in most cases.
If you deploy to Azure you might consider using either a Linux App Service or some Docker deployment mechanism altogether. You cannot use the In-Process IIS ASP.NET Core modules in these cases as far as I am aware of but at least deployments don't randomly fail.

Web Deploy results in ERROR_COULD_NOT_CONNECT_TO_REMOTESVC

We are trying to configure continuous integration with TFS 2012. While queuing a new build, the publish fails with the error:
Build FAILED.
"C:\src\ProjectName.sln" (default target) (1) ->
"C:\src\Website\ProjectName.csproj" (default target) (2) ->
(MSDeployPublish target) ->
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(4377,5): msdeploy error ERROR_COULD_NOT_CONNECT_TO_REMOTESVC: Web deployment task failed. (Could not connect to the remote computer ("ServerName") using the specified process ("Web Management Service") because the server did not respond. Make sure that the process ("Web Management Service") is started on the remote computer. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_COULD_NOT_CONNECT_TO_REMOTESVC)**
I checked all the points mentioned in the IIS.NET documentation for this error. Both services mentioned, Web Management Service and Web Deployment Agent Service, are running fine. A restart of those services has no change in behavior.
Windows Server 2008 R2 with IIS 7.
Web Deployment Agent Service is running on port 8172.
Web Deploy 3.0
Windows Firewall is not blocking any port on the server.
How can this be fixed?
If you install Web Deploy 3.x BEFORE Web Management Tools are installed, you'll have to re-install Web Deploy. I beat my head against the wall for hours on this.
Install the Web Management Services ("Turn Windows Features On/Off"/Roles -> Web Server -> Management Tools -> Management Service)
Then uninstall Web Deploy (repair didn't work) via the usual Add/Remove Programs control panel
Install Web Deploy 3.x again using Web Platform Installer.
Fixed. /Sigh
Double check in your Web Deploy settings that the name of the website is exactly that of what's in IIS.
Ben Day blogged more about it.
Fix that i saw on another website:
Fix it by adding “http://” to server.
In other words, when server is www.xxxx.com would get the 403 error, but when server is http://www.xxxx.com, then it works.
You need also to indicate the app name e.g 'Default Web Site/MyApp'
That was my error. Once I added /MyApp, it worked.
I got this error when using msdeploy, not TFS. In my case I needed to make sure the user msdeploy is using had permission to deploy to the website.
Find the website in IIS manager, right click and go to Deploy, then Configure Web Deploy Publishing. Find the user used by Web Deploy and setup for this website.
In my case the Internet proxy was enabled on source - which made msdeploy to reach out to internet instead of local ICN.
You should check the logs on your IIS first - see that you actually get to the server, and then you can locate the exact error here - https://support.microsoft.com/en-us/help/943891/the-http-status-code-in-iis-7-0-iis-7-5-and-iis-8-0
Uninstalling and re-installing (not repairing!) after setting up IIS did most of the magic for me.
There is another possible cause of the error. IIS Managemente Service have its own configuration for IP Address Restrictions, which default value is Deny Access for unspecified clients (Windows Server 2012 R2 with IIS 8.5).
You must set this value to Allow or add access to your specific IP address/IP address range using the Allow... button.
Remember, you must Stop the Management Service previously to change this configuration.

What rights are required for IIS to talk a WCF service hosted on a different machine?

In this question: ASP.NET web application unable to connect to WCF hosted as windows service
it's stated that the reason IIS could not talk to a WCF service hosted on a different machine is due to rights not assigned the app pool identity.
I'm facing the same problem I believe. What are these rights, and where do I set them?
Thanks.
This depends on the configuration of the service you're trying to access. However, if you're having trouble connecting to a different machine, you most likely don't have rights to access that computer using the machine account for the server hosting IIS. You could try adding [domain][iismachine] access to the target server (the one hosting the WCF service).
This overview has some pretty good information on what needs to be done in different scenarios.

Azure Compute Emulator Admin Priviledges - Registering WCF URL

I am working on upgrading a project to Windows Azure 1.3 and I am running into an issue with hosting WCF services in an Internal Web Role. I get the following exception when trying to access the services:
HTTP could not register URL http://127.0.0.1:5111/service.svc/. Your process does not have access rights to this namespace
I did have a similar issue when working with Azure 1.0 and resolved it by with the following code:
new BasicHttpBinding() { HostNameComparisonMode = HostNameComparisonMode.Exact }
With this new issue, there seem to be a few common solutions; using the above code, runing the httpcfg tool to explictly change namespace reservation, and running as Administrator.
As far as I know, the httpcfg tool will not work for an Azure Internal WebRole because the port is dynamically assigned. Running Visual Studio as Administrator and debugging the Cloud project does not fix the problem either (Visual Studio does launch the Emulator).
It seems like the Azure Compute Emulator does not inherit the permissions from the Visual Studio process. Has anyone run into a similar problem, any ideas on fixes, work-arounds?
Karl
Okay, my suspisions were proved correct. When the Azure Compute Emeulator starts, it adds the Web Role instances in IIS, but the App Pool Identity does not have permissions to register namespaces.
I found this blog article which describes how to change the identity of the app pool when a Web Role instance is started.
http://www.wadewegner.com/2011/01/programmatically-changing-the-apppool-identity-in-a-windows-azure-web-role/
This is a less than ideal solution, but works.