BulbFlash:-PayPal IPN and Windows Azure

While working with integrating PayPal with an MVC 3 app hosted on Azure, we just couldn’t get the PayPal IPN notification to work.

We were stuck with the following message!!

IPN delivery failed. Unable to connect to the specified URL. Please verify the URL and try again.

After a lot of brainstorming , tracing, debugging and re-reading the documentation , we realized that the issue was that our website had a custom endpoint of 8080 as against the default 80.

Paypal sends the IPN HttpPost request on port 80 so a request to http://xxx.cloudapp.net:8080/PayPalController/IPin will fail!!.. Ensure you are hosted on port 80!!

Hope this helps a few of you PayPal -Azure devs out there!!!

Team Cennest!!

Using InsertOrReplace/InsertOrMerge with the Storage Client!

Trying out the new Replace or Insert option(Upsert) in the Storage Client and can’t get rid of the following error message

“"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\r\n<error xmlns=\"http://schemas.microsoft.com/ado/2007/08/dataservices/metadata\">\r\n  <code>InvalidHeaderValue</code>\r\n  <message xml:lang=\"en-US\">The value for one of the HTTP headers is not in the correct format.</message>\r\n</error>"”

The main issue is that the new API is available only in the "2011-08-18" version which the storage dll does not hit . The reason the below code is necessary is because the released library sends an older storage version “2009-09-19” that does not support these newly released features

So we need to specifically set the headers in the data-context request. Also remember that this does not work with the local development storage ( at least as of now), so remember to use these headers ( and these operations) only with the Cloud storage account.

dataContext.SendingRequest +=
   (sender, args) => (args.Request).Headers["x-ms-version"] = "2011-08-18";

               dataContext.AttachTo(<tableName>, <data>);
               dataContext.UpdateObject(<data>);
             dataContext.SaveChangesWithRetries(SaveChangesOptions.ReplaceOnUpdate);

This gives you Insert Or Replace option with Storage Client Lib!!

If you leave the SaveChangeOptions.ReplaceOnUpdate option then you get Insert or Merge!

Until Next time!

Team Cennest!

When Azure Diagnostics just won’t collect your data!!!

Recently realized that while we had happily implemented tracing and diagnostics in our applications , tools like Cerebrata , Azure MMC etc were just not showing any trace data.. We were doing everything by the book and even re-opened the training kit but the trace just won’t get collected. After A LOT of investigation and googling/binging it comes to light that the most optimized way of collecting diagnostics changed with Azure SDK 1.3 and further with 1.4.

If you are victim of “No WADLogsTable “ being generated try the below snippet. It just might resolve your woes

public override bool OnStart()
{
DiagnosticMonitorTraceListener tmpListener = new DiagnosticMonitorTraceListener();
System.Diagnostics.Trace.Listeners.Add(tmpListener);
string wadConnectionString = "Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString";
CloudStorageAccount storageAccount =
CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue(wadConnectionString));

RoleInstanceDiagnosticManager roleInstanceDiagnosticManager =
storageAccount.CreateRoleInstanceDiagnosticManager(RoleEnvironment.DeploymentId,
RoleEnvironment.CurrentRoleInstance.Role.Name, RoleEnvironment.CurrentRoleInstance.Id);

DiagnosticMonitorConfiguration config = roleInstanceDiagnosticManager.GetCurrentConfiguration();
config.Logs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);
config.Logs.ScheduledTransferLogLevelFilter = LogLevel.Undefined;
config.DiagnosticInfrastructureLogs.ScheduledTransferLogLevelFilter = LogLevel.Warning;
config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);
config.Directories.ScheduledTransferPeriod = TimeSpan.FromMinutes(1D);

roleInstanceDiagnosticManager.SetCurrentConfiguration(config);
System.Diagnostics.Trace.TraceInformation("Diagnostics Running");

return base.OnStart();
}

Do let us know if this helped!!

Cennest!

Azure Table Storage Tip!

For all those working with Azure Table Storage and using the DateTime DataType, here is a quick tip!!

Ensure that you set the DateTime datatype with a valid value…while the dev fabric will allow you to get away without setting the value, the Azure prod fabric will not accept a junk value in the DateTime field and you will get a “One of the input values is out of range exception”!

Hope this helps save a few debug cycles as you move from Dev to Prod!!

Cennest!

We are Moving!

Cennest is finally moving to its new virtual home at www.cennest.com.

While we will be blogging at both places for sometime, you will find more information about “Whats Up at Cennest “ at our website.

Do visit!

Thinking of moving to the Cloud?

Cennest Technologies is a Microsoft Cloud Essentials Partner with focus on developing new applications/Migrating existing applications to the Cloud.

With in-depth knowledge of the framework and practical experience of custom development and live migrations we are aware of the usual bottlenecks you would face while trying to achieve an optimized deployment on Azure

Optimized on the Cloud= Performance+ Cost Optimization and Cennest has the knowledge you need to take the right decisions.

So get in touch with us at anshulee@cennest.com and lets reach for the clouds together!

Anshulee Asthana

Founder:- Cennest Technologies

We will move you to the Cloud!

Migrating ASP.Net MVC 1 to ASP.Net MVC 2

With release of ASP.NET MVC 2, are you planning to migrate your ASP.Net MVC 1 applications. Here are few links which would help you to migrate

  • Eilon Lipton has created migration tool for migrating ASP.NET MVC 1 solutions to ASP.Net MVC 2 solution over here
  • To manually upgrade project  one can find instructions at www.asp.net over here

This will help you to migrate solution, but it would not leverage features of ASP.Net MVC 2. For that you will need to manually change your code.

Also after using this tool or instruction, it would be required to check if solution is able to build successfully and if building it with ASP.Net MVC 2 has lead to any logical bugs, since there are couple of breaking changes introduced in ASP.Net MVC 2