Code to handle swapping websites based on DNS entries. Used for Blue Green deployments on premise.
public class DnsDeploy
Current IP Address of the website as defined in DNS on the client
Name of the site: A or B
Waiting for a DNS change to finish
IP Address as defined on DNS server. This can be different to the client until the DNS change has finished.
TTL of the DNS entry on the DNS server.
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.
DNS name of the DNS Server
Username of account with permissions to change DNS server settings.
Password of account with permissions to change DNS server settings.
Name of the DNS entry to adjust. The is the normal website URL.
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.
DNS name of the DNS Server
Username of account with permissions to change DNS server settings.
Password of account with permissions to change DNS server settings.
Name of the DNS entry to adjust. The is the normal website URL.
The IP address of the SiteA DNS entry.
The IP address of the SiteB DNS entry.
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);}Please see examples on Auspork Ops or Dandy Docket