Update IIS binding in configuration file, not GUI - iis

Can I update IIS binding in configuration file? I have six servers, needing to sync bindings among them.
Do you have any idea to facilitate my task? Thanks.

You sure can use Bindings/Binding element in the web server's ApplicationHost.config (not Web.Config) to setup multiple bindings directly similar to as below however be sure to keep the setting site specific so bindings reflect correct setting to specific site:
<site name="Contoso" id="2">
<application path="/" applicationPool="Contoso">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="192.168.0.1:443:www.contoso.com" />
<binding protocol="https" bindingInformation="*:443:" />
</bindings>
</site>
More info:
http://www.iis.net/ConfigReference/system.applicationHost/sites/site/bindings/binding

Related

Deploying to new D-series Azure VM's

I'm trying to deploy a test instance of our Azure-based webservice to the new D-series Azure vm's. We make extensive use of temp files and are hoping we'll see some good performance improvements. Unfortunately we don't seem to be able to package or build using the new vmsizes. Our current csdef looks like this:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="WebAPI.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2013-10.2.2">
<WebRole name="WebAPI" vmsize="Large">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="NonSSL Endpoint" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="NonSSL Endpoint" protocol="http" port="80" />
<InternalEndpoint name="InternalHttpIn" protocol="http" />
</Endpoints>
</WebRole>
</ServiceDefinition>
If I switch the vmsize from "Large" to "Standard_D3" and try to build or package for publishing, I get this error:
Error 2 The XML specification is not valid: The 'vmsize' attribute is invalid - The value 'Standard_D3' is invalid according to its datatype 'http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition:RoleSize' - The Enumeration constraint failed. C:\Users\ablack\Desktop\WebAPI.Azure\ServiceDefinition.csdef 3 34 WebAPI.Azure
How do I get this schema updated? Or is there a way to override XML validation during the build & package process?
Apparently the 2.4 SDK removes the vmsize constraint entirely (it accepts any values, including made-up values like "Supersize"), so we will have to upgrade to that to try any new size options. This will complicate benchmarking (we'll need to get fresh baselines with the updated SDK first), but c'est la vie.

Cannot access RoleEnviroment when running multiple Sites inside Cloud Service

I have got an existing solution which uses settings from RoleEnviroment in both the WebRole.OnStart and Global.asax Application_Start handlers. (This has been running well for months)
This all works fine when I have just one Site inside my role:
<WebRole name="WebRole" vmsize="ExtraSmall">
<Runtime executionContext="elevated" />
<Sites>
<Site name="Web1" physicalDirectory="..\..\..\Web1\">
<Bindings>
<Binding name="HTTP" endpointName="Public HTTP" hostHeader="web1.com" />
</Bindings>
</Site>
</Sites>
However when I add my second site, neither site can access RoleEnviroment??
<WebRole name="WebRole" vmsize="ExtraSmall">
<Runtime executionContext="elevated" />
<Sites>
<Site name="Web1" physicalDirectory="..\..\..\Web1\">
<Bindings>
<Binding name="HTTP" endpointName="Public HTTP" hostHeader="web1.com" />
</Bindings>
</Site>
<Site name="Web2" physicalDirectory="..\..\..\Web2\">
<Bindings>
<Binding name="HTTP" endpointName="Public HTTP" hostHeader="web2.com" />
</Bindings>
</Site>
</Sites>
I have tested this in the local azure emulator (full) and it works fine, but when deployed to an actual web role it throws:
[SEHException (0x80004005): External component has thrown an exception.]
RdGetApplicationConfigurationSetting(UInt16* , UInt16** ) +0
RoleEnvironmentGetConfigurationSettingValueW(UInt16* pszName, UInt16* pszDest, UInt64 cchDest, UInt64* pcchRequiredDestSize) +73
Microsoft.WindowsAzure.ServiceRuntime.Internal.InteropRoleManager.GetConfigurationSetting(String name, String& ret) +133
Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetConfigurationSettingValue(String configurationSettingName) +109
Web1.Installer.Install(IWindsorContainer container, IConfigurationStore store) in c:\projects\Webs\Web1\Installer.cs:21
I have checked that the setting I am trying to access is there. When I remove the second Site it works fine. When I remove the first Site it also works fine. It looks to me like there is an issue with Azure providing access to the RoleEnviroment for web roles in multiple instances.
Okay, so after working on this for almost 2 days. The issue turned out to be mismatching Azure SDK version assemblies on the projects.
The older Site had Azure SDK 2.4, and for some reason the newer Site had SDK 2.3, this meant the RoleEnvironment could not be found when there was two sites (both version of the assembly) deployed.
I assume this is because they are looking for the RoleEnvironment differently, or are conflicting in how they access it.
I've read that this may be related to the 'Rd' environment variables that may cause RoleEnvironment to be IsAvailable = false.
So guys: Check your Azure SDK assembly versions are sync if you encounter this issue!

Images from outside wwwroot not displaying (despite mapping)

In my ColdFusion application, I want to keep the images outside of wwwroot in this folder: C:\extSite\stdImages
I created a mapping in wwwroot\WEB-INF\jrun-web.xml like this:
<virtual-mapping>
<resource-path>/extStdImages</resource-path>
<system-path>C:\extSite\stdImages\</system-path>
</virtual-mapping>
To display an image, I do this:
<img src="/extStdImages/abc.jpg">
This works fine on my dev site (which is using ColdFusion's built-in web server), but the image does not display in production (where I am using IIS). I am wondering if I have to tweak something in IIS or elsewhere on the production server to allow access to these files.
Can anyone help? Thanks in advance!
Peter
In iis you would need to create a virtual dir that points to the images folder. Although putting images outside the wwwroot is pointless as they must be web accessible in order for them to display on a web page. The only reason to do this would be.if you were protecting copyright images with passwords and not linking to them directly.
If your on IIS, you may want to look at this for your web.config
http://www.iis.net/configreference/system.applicationhost/sites/site/application/virtualdirectory
here is a sample:
<site name="Contoso" id="2" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="C:\Contoso\Content" />
</application>
<application path="/CRM">
<virtualDirectory path="/" physicalPath="C:\Contoso\Content\CRM" />
<virtualDirectory path="/Images" physicalPath="E:\Images" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:80:www.contoso.com" />
</bindings>
</site>
This is wrong C:\extSite\stdImages\
You have to use slashes not backslashes for CF
This is correct and works C:/extSite/stdImages/

VS2012 changes my IIS Express configuration file detrimentally when opening solution

Given the following site, configured within applicationHost.config for IIS Express 7.5
<site name="MySite" id="1">
<application path="/" applicationPool="Clr2IntegratedAppPool">
<virtualDirectory path="/" physicalPath="path\to\the\site" />
<virtualDirectory path="/VDir1" physicalPath="path\to\the\site" />
<virtualDirectory path="/VDir2" physicalPath="path\to\the\site" />
<virtualDirectory path="/VDir3" physicalPath="path\to\the\site" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:12345:localhost" />
</bindings>
</site>
When opening this solution, from Source Control Explorer (TFS2010) using VS2012 - the act of opening the solution changes the XML structure so that each virtualDirectory node lives inside it's own application node (which VS2012 creates for me)
As this is a legacy .NET 2.0 application, which in it's wisdom, references controls, files, etc across the virtual directories shown above - as soon as they are given their own application in the config file any calls from / to /VDir1 or /VDir1 to /VDir3 (for example) fail with the error "The virtual path X maps to another application, which is not allowed"
I have no problem with that error and it's validity, but does anybody know how I can stop VS2012 from meddling with my config file.
Couple of other points
applicationHost.config is source controlled (trivial)
Solutions in question are set to "Use IIS Express" with the configuration settings such as hostname, port set inside the project properties.

is it possible to hang a few web sites in one role at a port of Azure?

http://msdn.microsoft.com/en-us/library/windowsazure/gg433110.aspx
<Site name="ClientService" physicalDirectory="..\qwer.ClientService">
<Bindings>
<Binding name="ClientService" endpointName="EndpointClientService" hostHeader="ClientService.tsasdc.com" />
</Bindings>
</Site>
error
Error 1 The same local port '80' is assigned to input endpoints EndpointImageService and Endpoint1 in role qwer.Web. C:\Users\Administrator\Desktop\prohect\src\qwer.Azure\ServiceDefinition.csdef 1 1 qwer.Azure
You must use one and the same EndPoint for all the sites you need. That is the need for defining the "hostHeader" in each Binding. For example, if you want a port 80 HTTP endpoint - you may have only one endpoint per Hosted Service. And you just map all your sites to the same endpoint.
Endpoint1 is predefined HTTP input endpoint on port 80 when you have Web Role. You can either rename it to something more meaningful, or just use it for your second site, and never create second input endpoint on HTTP protocol and port 80.
You can have a few web sites, but they each have to point to their own unique port. If you had multiple on the same port, it wouldn't know which one to send the request to.
both of your sites should have the same endpoint name.
you got site with endpoint name Endpoint1;
the second site ( with the physicalDirectory attr) should go to the same endpoint with a hostHeader you already put.
<Sites>
<Site name="Web">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" />
</Bindings>
</Site>
<Site name="Web2" physicalDirectory="XXX">
<Bindings>
<Binding name="Endpoint1" endpointName="Endpoint1" hostHeader="YOUR HOST HEADER" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
</Endpoints>`

Resources