I had a recent requirement from one of our clients that took a little bit of tinkering to figure out… we will call our client Contoso LLC. and our project that we host for them we will call the “Cool Widget Project.”

We built a really neat widget of an application for Contoso to use and we are hosting it under a sub-domain of a domain we control. We needed to keep hosting it under this domain. However, our client, Contoso, wanted to hand out a link for their users to the new widget we built using an existing sub-domain from a domain they control. This was of course under their main domain, constosollc.com, and they already had existing users that came to the old version of the widget (built by another vendor) at widget.contosollc.com.

Our company was hosting the new widget app at widgetapp.appworks.net.

To further complicate things… our company appreciates security, likes fast DNS updates, and the app really benefits from using a CDN… so we are using Cloudflare to manage DNS for the appworks.net domain. Better yet, we also like the cloud, and this new widgetapp is actually an Azure Web App.

So there’s the situation…

We essentially need this to happen:

User visits widget.contosollc.com --> widgetapp.appworks.net.

Oh but this is Azure… so actually widgetapp.appworks.net is already a CNAME record and it actually points to widgetapp.azurewebsites.net. So it is this:

User visits widget.contosollc.com --> widgetapp.appworks.net --> widgetapp.azurewebsites.net.

To elaborate the above just a little bit more:

widget.contosollc.com (DNS from random provider) --> widgetapp.appworks.net (Cloudflare DNS, CNAME) --> widgetapp.azurewebsites.net (the DNS name provided by Azure for the application)

Simple right? Just get our client to create a CNAME record that points to widgetapp.appworks.net and move on with life… wrong…
(more…)

This is redacted version of a powershell script I had to come up with recently to fix an issue with a web application in our environment.

$hostsPath = "$env:windir\System32\drivers\etc\hosts"
$ip = ipconfig | findstr /i IPv4 |Out-string
$ip = $ip.TrimStart("IPv4 Address. . . . . . . . . . . : ")
$ip = $ip.TrimEnd("`n")
$ip = $ip.TrimEnd("`r")
Clear-Content $hostsPath
ipconfig /flushdns
Add-Content $hostsPath "$ip siteurl.com"

I will walk through what is going on here…
(more…)

I had some trouble finding some good examples of syntax and full explanation for creating VHD files (attaching new hard drives) from the Azure Powershell command line and attaching them to existing VMs. Here is my quick and dirty method of doing just that…
(more…)