I have two projects in my solution:
1. WCF Service Library
2. MVC project Azure free website which uses the WCF service.
Everything works as it should when not deployed, (localhost), but I have no idea how to use my WCF service from my MVC project when I have deployed my MVC project to Azure.
Solution:
WCF Service Library project app config:
<client>
<endpoint address="http://localhost:8080/UserWCF" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IUserService" contract="Fildela_WCF.IFildelaService"
name="WSHttpBinding_IUserService">
<identity>
<userPrincipalName value="REFT\filip" />
</identity>
</endpoint>
</client>
<services>
<service name="Fildela_WCF.FildelaService">
<endpoint address="UserWCF" binding="wsHttpBinding" contract="Fildela_WCF.IFildelaService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080" />
</baseAddresses>
</host>
</service>
</services>
MVC project web config:
<client>
<endpoint address="http://localhost:8080/UserWCF" binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IFildelaService" contract="FildelaServiceReference.IFildelaService"
name="WSHttpBinding_IFildelaService">
<identity>
<userPrincipalName value="DEFAULT\Filip" />
</identity>
</endpoint>
</client>
How I use my service on localhost:
Right click Service References folder in my MVC project and click "Add Service Reference".
Click discover and select the localhost service that pops up under Services.
I can now access my functions that resides in my WCF project: ServiceClient1 test = new ServiceClient1();
Test.HelloWorld();
I have tried to replace the localhost address with my azure website but it doesn't work, (mywebsite.azurewebsites.net).
I am all new with this so bear with me. I have two projects in my solution now and when I publish my MVC project, the WCF project wont come with the publish, right?
So how am I supposed to use the WCF project from my MVC project when the web project is published to Azure?
Am I supposed to use an Azure Service Bus?
Should I go with cloudapp instead?
How? What? Why?
Thank you very much
I have decided to convert my Azure website project to an cloudapp project. Publishing two seperat Azure websites just because of the WCF service is not very efficient.
Related
My ASP.NET MVC application is deployed on Azure app service and was working until today. It won't let me login anymore through the application which uses ASPNET membership. If I run the application in Visual Studio locally pointing to the production azure sql db it works. The deployed app can read data fine but it seems when it tries to login it doesn't while deployed on azure. I haven't changed any code so I don't know why it stopped working on azure when it was. It still allows for reading of data, it displays items in a browse page. I saw this error when I disabled custom errors:
A network-related or instance-specific error occurred while
establishing a connection to SQL Server. The server was not found
or was not accessible. Verify that the instance name is correct and
that SQL Server is configured to allow remote connections. (provider:
SQL Network Interfaces, error: 26 - Error Locating Server/Instance
Specified)
I've checked these questions but they didn't seem to make it work:
Azure SQL firewall
Network interface azure
Azure passwords
Hashed passwords
login works locally not on azure
azure debugging
login register locally not on azure
UPDATE
I used remote debugging and it's failing in a razor view when I check the roles using this line:
if (User.IsInRole("Administrator")) {
I don't know why it was working for a while then stopped but this is what I did to fix it. It was trying to connect to an old membership database connection LocalSqlConnection from a machine.config file. I saw it creating the aspnetdb.mdf in the AppData folder when I would run in visual studio but I am using ASP.NET Identity. I had to modify my web.config like this keep it from using the local db:
Comment out these:
<!--
<membership>
<providers>
...
</providers>
</membership>
<profile>
<providers>
...
</providers>
</profile>
<roleManager>
<providers>
..
</providers>
</roleManager>
-->
Add this:
<modules>
<remove name="RoleManager"/>
</modules>
Add this in <connectionStrings>
<add name="LocalSqlServer" connectionString="same as application database connectionstring"...
The answer from #clayRay in this question gave me most of the answer:
How do I stop using ASPNETDB.MDF in LocalDB?
In Visual Studio my project builds and runs with no problem. When deploying to Windows Server 2012 R2 I encounter the following error:
A default document is not configured for the requested URL, and
directory browsing is not enabled on the server.
I have installed all 4.5 and other Roles and Profiles, have given permission to the folder to everyone and have read every article and tried to implement every suggestion to no avail..
I'm out of options, spent weeks on this and cannot understand how this is so convoluted just to deploy a site.. Can someone advise? Thanks
Edit - this is for Windows Server 2012 and I have tried suggested alternatives such as adding runAllManagedModulesForAllRequests to my web.config.
Edit When deploying I build the solution in Release mode and copy the bin, views, content and scripts folders over to Windows Server. In IIS I then make the folder an application, making sure a 4.0 App Pool is assigned and still receive the error.
Final Edit
Publish allowed me to see the structure that needed to be copied over. There were also 3 dll's that needed to be copied local from Visual Studio:
System.Web.Http.dll
System.Web.Http.WebHost.dll
System.Net.Http.Formatting.dll
As well as Web.Config dependentAssembly updated to take into account some MVC4 dll's such as Unity.Mvc4 pointing to MVC3 binaries.
This error message gives a clue as to the problem. MVC sites do not rely on documents or web pages in the way that WebForms do, the default mode for IIS. They depend on a special handler that deals with the RESTful urls used to pass requests to your application.
In your web.config file, check that the following config is present in the system.webServer section:
<system.webServer>
<handlers>
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<remove name="OPTIONSVerbHandler" />
<remove name="TRACEVerbHandler" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
Then on your web server, open the IIS Manager, navigate in the Connections panel on the LHS to the node that represents your application, then double-click on the Handler Mappings icon in the Features View tab. Check that the ExtensionlessUrlHandler-Integrated-4.0 handler is enabled (see below).
If that doesn't do the trick, double-check that you have the ASP.NET 4.5 Role enabled on the server. See http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-using-aspnet-35-and-aspnet-45#TOC301258515 for instructions.
Also make sure you application is running under an AppPool that is configured for .NET 4.0.
I recommend you to use Publish Tool in Visual Studio by right clicking on project in solution explorer to deploy resultant files on the web. Then try the followings:
Reinstall .Net framework and MVC using Web PI.
Put a dummy default.aspx file in the root folder (this will not be
used when MVC is working, but can get rid of this problem).
Try running the aspnet_regiis -i command in the Visual Studio 64
bit command prompt (with admin privileges), then deploy it.
Take a look at Default Document configuration in IIS.
I wish to be solved.
Seems like IIS has not considered your application as a web application. It must be a MVC version mismatch.
As it is tagged as MVC4, we have 3 inner versions in MVC4. Check the server for which version of MVC is installed.If it is not installed or if you dont want to install MVC in the server, set CopyLocal=true for all the assemblies that you have referred in your project and re-publish the application and deploy in the server.
Is it possible to run Quartz.Net in an Azure WebJob and communicate with it using a RemoteClient proxy? If so, how could I figure out what the address would be?
<quartz>
<add key="quartz.scheduler.instanceName" value="RemoteClient"/>
<add key="quartz.scheduler.proxy" value="true"/>
<add key="quartz.scheduler.proxy.address" value="tcp://127.0.0.1:555/QuartzScheduler"/>
</quartz>
I know that Azure has its own scheduling mechanisms, but my application has to run in both Azure and Self-Hosted environments.
The Azure WebJob has the same sandbox limitation as the Azure Website in which it cannot open an arbitrary port and listen on it.
One possible way to communicate with a WebJob is via persistent queues (like Azure storage queue, servicebus queue or any other).
My work has some dedicated web servers (Server 2008R2, IIS7). Currently everything done here before has just been asp.net webforms. For a new project I want to finally introduce them to MVC. I have a vanilla MVC application created in VS2013. I walked through some different sites and got it set up on my local IIS (full, not express) just fine. I can hit 'localhost' and see the site I created. I am using web deploy, and it worked very well.
After that I moved on to our development server. I set it all up the same (i.e new website in iis, web deploy set up with proper credentials, etc). Publishing from VS works. On the development server I see all the files there, but in IIS on the server (via RDP session) I cannot browse to it. It does not give me a 404 or 503 error, internet explorer just tells me that it can't find the address.
Based off the many, many articles I went through I did the following:
aspnet_regiis.exe -i (32 and 64 bit)
Made sure the server has Web Deploy 3.5 and Web Deploy tools 2.1 installed.
Added some lines to my web.config (see below)****.
made sure the server had .net 4.5 and mvc installed.
After all that it still will not show me the site. Anything I am missing? I would love to find a tutorial to walk me through baby-step by baby-step, but all I see out there assumes that you already have x and y set up, or you already know IIS like the back of your hand.
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
</modules>
To deploy MVC4 Application onto IIS 7.5
Make sure that you installed the latest framework.
Go to %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe –ir for 32 bit or
%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe –ir for 64 to register asp.net
To be able to work with sites in MVC for IIS7 ir IIS7.5 please update it (http://support.microsoft.com/kb/980368).(Good)
Make sure that there is:
<modules>
<remove name="UrlRoutingModule-4.0" />
<add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule"
preCondition="" />
<!-- any other modules you want to run in MVC
e.g. FormsAuthentication, Roles etc. -->
</modules>
in web.config. (Good)
Make sure that there is
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
in web.config.(Bad)
from own experience... use "Good"
I'm trying to perform a VIP swap via the azure portal and I'm getting the error:
Windows Azure cannot perform a VIP swap between deployments that have a different number of endpoints.
I looked closer and I DO see difference in # of endpoints (2 in production vs 3 in staging).
Production:
Input Endpoints
OUR.API:168.62.21.50:80
OUR.API:168.62.21.50:3389
Staging:
Input Endpoints
OUR.API:168.62.22.55:80
OUR.API:168.62.22.55:3389
OUR.API:168.62.22.55:8172
Port 80 is web and 3389 is remote desktop. So far so good. Where is that additional port, 8172, coming from? Nothing in the application listens to anything other than port 80. Plus the applications in the staging and production areas are almost identical - so it's gotta be the framework. Any steps in narrowing this down?
[edit]
Also, my role's ServiceDefinition.csdef has just one endpoint defined:
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>
"Where is that additional port, 8172, coming from?"
It is from WebDeploy being enabled in the publishing settings
Long answer:
I parsed the entire configuration one by one between the staging and production, here is what I found:
Your publishing settings are saved to
<azurerole>\Profiles\<yourprofilename>.azurePubxml
My production deployment had
<AzureEnableWebDeploy>True</AzureEnableWebDeploy> while my staging deployment had <AzureEnableWebDeploy>False</AzureEnableWebDeploy>
The Azure infrastructure then looks that up and opens port 8172 to enable WebDeploy on the staging roles. So that's why the endpoints are different despite no new endpoint defined in the ServiceDefinition.csdef file.
I'm not sure why having different number of endpoints should prevent an Azure Publication itself.
For me the issue was that my PROD instances had RDP enabled and the STAGING did not. So "RDP" was the endpoint that was different.