DnsDeploy

Code to handle swapping websites based on DNS entries. Used for Blue Green deployments on premise.

Constructors

public class DnsDeploy

Properties

public class DnsInfo
public string IpAddress

Current IP Address of the website as defined in DNS on the client

public string Site

Name of the site: A or B

public bool Refreshing

Waiting for a DNS change to finish

public string ServerIp

IP Address as defined on DNS server. This can be different to the client until the DNS change has finished.

public string Ttl

TTL of the DNS entry on the DNS server.

Methods

public DnsInfo DnsDeploy(string dnsServer, string dnsUser, string dnsPassword, string dnsName, string dnsIpA)

This returns a DnsInfo object with information to be displayed on a page about the current Site that is live.

string dnsServer

DNS name of the DNS Server

string dnsUser

Username of account with permissions to change DNS server settings.

string dnsPassword

Password of account with permissions to change DNS server settings.

string dnsName

Name of the DNS entry to adjust. The is the normal website URL.

string dnsIpA

The IP address of the SiteA DNS entry. This is used to compare against to determine which Site is currently live.

public DnsInfo DnsSwap(string dnsServer, string dnsUser, string dnsPassword, string dnsName, string dnsIpA, string dnsIpB)

Swaps the current site for the inactive site. ie: If Site A is current then Site B will become current and vice-versa.

string dnsServer

DNS name of the DNS Server

string dnsUser

Username of account with permissions to change DNS server settings.

string dnsPassword

Password of account with permissions to change DNS server settings.

string dnsName

Name of the DNS entry to adjust. The is the normal website URL.

string dnsIpA

The IP address of the SiteA DNS entry.

string dnsIpB

The IP address of the SiteB DNS entry.

Example

C#
public ActionResult Dns()
{
var dd = new DnsDeploy();
var r = dd.PopulateDnsContext(AppValue.DnsServer, AppValue.DnsUser, AppValue.DnsPassword, AppValue.DnsName, AppValue.DnsIpA);
var dd = new DnsDeploy();

return View(r);
}

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult DnsSwap()
{
var dd = new DnsDeploy();
dd.DnsSwap(AppValue.DnsServer, AppValue.DnsUser, AppValue.DnsPassword, AppValue.DnsName, AppValue.DnsIpA, AppValue.DnsIpB);
var r = dd.PopulateDnsContext(AppValue.DnsServer, AppValue.DnsUser, AppValue.DnsPassword, AppValue.DnsName, AppValue.DnsIpA);

return View("Dns", r);
}

Razor

Please see examples on Auspork Ops or Dandy Docket