Sunday, February 20, 2011

Amazon Route 53: .Net library is here.


At the end of the year 2010, Amazon has launched a new web service called “Amazon Route 53” which is focused on operating DNS. Addition of this web service in the stack of Amazon web service suite has made hard for the competitors to stand near the Amazon.
Amazon Route 53 is designed to be fast, easy to use, easy to program and cost effective.  An easy to use API has made it easy to integrate this service into an existing application and let you offer the UI of your own choice to your users.   
What is Amazon Route 53?
The name Amazon Route 53 comes from the fact that port 53 is used to entertain the DNS queries. According to Amazon
“Amazon Route 53 is a highly available and scalable Domain Name System (DNS) web service. It is designed to give developers and businesses an extremely reliable and cost effective way to route end users to Internet applications”.
It also provides a programmatic access to work with DNS like adding, modifying or deleting DNS records.
Amazon Route 53 and .Net
Amazon has exposed an XML  RESTful web service API for programmatic access. Dealing with the raw RESTful request and response is very much painful and prone to errors. But thanks to the WCF architecture which enables .net developers to deal with this raw data as strongly typed classes and takes care of the complicated coding part itself. But the real art is how to configure and code WCF to lessen the pain and increase the gain.
Here is my library with source code for you. Amazon.Route53 is now moved to codeplex. It is free to use.
If you find any better way to code Route 53 or any bug in my code then please let me know.

5 comments:

  1. First off all thanks for sharing the code!
    I have a problem when I use GetHostedZoneById and DeleteHostedZone. The program said HTTP request was forbidden with client authentication scheme 'Anonymous'. But I can create and list zones.
    Any suggestion? Thanks.

    ReplyDelete
  2. I am also getting the same issue.
    Can you help in it?

    [System.ServiceModel.Security.MessageSecurityException] = {"The HTTP request was forbidden with client authentication scheme 'Anonymous'."}

    Server stack trace:
    at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory factory)
    at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
    at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
    at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
    at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
    at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
    at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
    at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

    Exception rethrown at [0]:
    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
    at Amazon.Route53.IAmazonRoute53.ChangeResourceRecordSets(String HostedZoneId, ResourceRecordSetsChangeRequest Request)
    at Amazon.Route53.AmazonRoute53.ChangeResourceRecordSets(String HostedZoneId, ResourceRecordSetsChangeRequest Request) in D:\Downloads\Amazon.Route53\Amazon.Route53\Amazon.Route53\Client\AmazonRoute53.cs:line 114
    at Amazon.Route53.Test.Main(String[] args) in D:\Downloads\Amazon.Route53\Amazon.Route53\Amazon.Route53\Test.cs:line 58

    ReplyDelete
  3. The Anonymous problem is because you must be creating the AmazonRoute53 object with the credentials inverted ... I had the same problem, change the order and now works fine.

    //Incorrect
    Amazon.Route53.AmazonRoute53 ar53 = new Amazon.Route53.AmazonRoute53(
    GlobalSettings.Instance.GetSetting(GlobalSettings.Setting.S3_ACCESS_KEY),
    GlobalSettings.Instance.GetSetting(GlobalSettings.Setting.S3_KEY_ID));
    //Correct
    Amazon.Route53.AmazonRoute53 ar53 = new Amazon.Route53.AmazonRoute53(
    GlobalSettings.Instance.GetSetting(GlobalSettings.Setting.S3_KEY_ID),
    GlobalSettings.Instance.GetSetting(GlobalSettings.Setting.S3_ACCESS_KEY));

    ReplyDelete