Azure App Service – Forcefully redirecting from HTTP to HTTPS the easy way!

The easiest, non techie way is to add the ‘Redirect HTTP to HTTPS’ Extension kindly created by Greg Hogan (https://github.com/gregjhogan)

In the Azure Portal, select ‘Extensions’ in the App Service blade

azure-redirect-1

Add a new Extension by clicking on the ‘+Add’ button at the top
Select the ‘Redirect HTTP to HTTPS’ extension from the list given.

azure-redirect-2

Agree to the T&C’s
Wait till it’s installed and then restart the service (which you can find in the ‘Overview’)

After this when you access the website with http or without http/https, it will automatically redirect to https.

Webinar : Windows Azure Basics

I presented this webinar online on 10th Feb, 2014. I hope it would have been a fun experience for people.

This webinar followed the following topics relating to Windows Azure:

– Windows Azure Basics
– Windows Azure Storage
– Tools and Technology
– Windows Azure Mobile Services
– How to build apps using Windows Azure Mobile Services
– Introduction to Azure portal
– Different Services offered by windows Azure

Some key links and notes:

http://www.windowsazure.com

To get PublishSetting profile visit the link below:
•https://windows.azure.com/download/publishprofile.aspx

A publishsettings file will be downloaded and the file name will be in given format:

-credentials.publishsettings

Windows Azure Session [ Advance Programming ]

 WINDOWS AZURE

The session was delivered at TEO Intl. on 30th of August 2012, where developers and students joined us for a chance to learn more about Windows Azure and Cloud Platform. The session was conducted successfully, with heavy focus on development on Windows Azure along with the benefits one gets by using Cloud services for hosting web applications.

Windows Azure is Microsoft’s application platform for the public cloud. You can use this platform in many different ways. For instance, you can use Windows Azure to build a web application that runs and stores its data in Microsoft datacenters. You can use Windows Azure just to store data, with the applications that use this data running on-premises (that is, outside the public cloud). You can use Windows Azure to create virtual machines for development and test or to run SharePoint and other applications. You can use Windows Azure to build massively scalable applications with lots and lots of users. Because the platform offers a wide range of services, all of these things-and more-are possible.

To do any of them, though, you need to understand the basics. Even if you don’t know anything about cloud computing, Microsoft organized a training session that walked through the fundamentals of Windows Azure. The goal was to give a foundation for understanding and using this cloud platform.

Ali Sufyan was the trainer for this training. He is currently the Senior Software Engineer at Talented Earth Organization (TEO), and holds a prominent position in the domain of cloud computing. The discussion also briefly catered the Concepts of Windows Azure, Cloud Computing, SQL Azure, Architecture and Components of Windows Azure etc.

Lets have a glimpse of the session:

[simple_slideshow]

 

Azure Service Bus Relay using BasicHttpRelayBinding

I have been tasked to Expose my service that reside on a network that is behind a firewall. Obvious choice was to utilize Azure Service Bus. The Relay mechanism provided by the service bus is a real magical scenerio that a developer can ever have.

The first demo i created was using netTCP binding mechanism. That sure is fast but the requirement was to do with BasicHttpRelayBinding. So let me guide you step by step how to do it.

Steps:

1- Login to Azure portal using the credentials of your subscription.

2- Click on the option from left panel “Service Bus, Access Control & Caching”.

3- Selecting Option “New”, will open a dialog to create a new ServiceBus namespace. Provide a name in namespace. Check for availability of namespace. Select the region. Choose your subscription and click “Create Namespace” button. This will start creatig a namespace for you.

4- Once your Service Bus is active, click on “Default Key” Button on bottom right.

Note down the “Default Issuer” and “Default Key” values. We will use in our code to connect and relay messages with the service bus.

5- Now comes the coding part. We will first create a Server and than we will create a client.

SERVER:

First create a Server app that will be a Console Application.

a- In the console app, add new item that would be a WCF Service.

It will create two classes IService1.cs and Service1.cs, plus some modifications in the web.config file.

Lets see the code of IService1.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Runtime.Serialization;

using System.ServiceModel;

using System.ServiceModel.Web;

using System.Text;

namespace testServer {

[ServiceContract(Name = “IService1”, Namespace = “https://test.servicebus.windows.net/Service1/“)]

public interface IService1

{

[OperationContract, WebGet]

string GetData();

}

}

 Lets now see the Service Implementation:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Runtime.Serialization;

using System.ServiceModel;

using System.Text;

namespace testServer {

public class Service1 : IService1     {

public string GetData()

{

return “Hello World”;

}

} }

So the service method will just be returning a hello world to the client.

Lets see the code of our program.cs, which will actually host this service and bind with Service Bus relay through basicwebhttprelaybinding

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Microsoft.ServiceBus;

using System.ServiceModel.Web;

using System.ServiceModel.Description;

using System.ServiceModel.Dispatcher;

using System.ServiceModel.Channels;

using System.Xml;

using System.IO;

using System.ServiceModel;

namespace testServer

{

class Program

{

static void Main(string[] args)

{

ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;

// Configure the credentials for the service and client endpoints through an endpoint behavior.

var endPoint = new TransportClientEndpointBehavior();

endPoint.CredentialType =TransportClientCredentialType.SharedSecret;

endPoint.Credentials.SharedSecret.IssuerName =“owner”;

endPoint.Credentials.SharedSecret.IssuerSecret =“[your secret key you copied from Step 4]”;

// Create the binding with custom settings.

var binding = new BasicHttpRelayBinding();

binding.Security.RelayClientAuthenticationType =RelayClientAuthenticationType.RelayAccessToken;

// Get the service URI.       [below testServer is the namespace of Service bus we created in Azure in start]

var address = ServiceBusEnvironment.CreateServiceUri(“https”, “testServer”, “Service1”);

// Create the web service host.

var host = new WebServiceHost(typeof(Service1), address);

// Add the service endpoint with the WebHttpRelayBinding binding.

host.AddServiceEndpoint(typeof(IService1), binding, address);

// Add the credentials through the endpoint behavior.

host.Description.Endpoints[0].Behaviors.Add(endPoint);

//host.Description.Endpoints[0].Behaviors.Add(new MyBehavior());

host.Description.Behaviors.Add(new ServiceMetadataBehavior() { HttpsGetEnabled = true });

ServiceRegistrySettings settings = new ServiceRegistrySettings();

settings.DiscoveryMode =DiscoveryType.Public;

foreach (ServiceEndpoint s in host.Description.Endpoints)

s.Behaviors.Add(settings);

ServiceDebugBehavior debug = host.Description.Behaviors.Find<ServiceDebugBehavior>();

// if not found – add behavior with setting turned on 

if (debug == null)

{

host.Description.Behaviors.Add(new ServiceDebugBehavior() { IncludeExceptionDetailInFaults = true });

}

else

{

// make sure setting is turned ON

if (!debug.IncludeExceptionDetailInFaults)

{

debug.IncludeExceptionDetailInFaults =true;

}

}

// Start the service.

host.Open();

    Console.WriteLine(“Copy the following address into a browser to see the data: “);

    Console.WriteLine(address );

    Console.WriteLine();

    Console.WriteLine(“Press [Enter] to exit”);

Console.ReadLine();

host.Close();

}

}

That is all from the Server End, we will just run the project on the Server.

Now comes the client part. We need the Service proxy class on the client to communicate with the WCF Service on the Server.

We can generate on by typing the following command in the comand prompt

svcutil.exe http://localhost:62343/Service/Service1.svc /d :c:\filestosavehere\  [ path could be different based on your settings and parameters ]

Create a project on client with name testClient and copy the Service1.cs file generated in the client project.

Open program.cs on client project and use the following code.

using System;

using System.Collections.Generic;

using System.IO;

using System.Linq;

using System.ServiceModel;

using System.ServiceModel.Channels;

using System.ServiceModel.Description;

using System.ServiceModel.Dispatcher;

using System.ServiceModel.Web;

using System.Text;

using System.Xml;

using Microsoft.ServiceBus;

using Microsoft.ServiceBus.Description;

namespace testClient

{

class Program

{

static void Main(string[] args)

{

ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.Http;

var relayCredentials = new TransportClientEndpointBehavior

{

CredentialType =TransportClientCredentialType.SharedSecret

};

relayCredentials.Credentials.SharedSecret.IssuerName =“owner”;

relayCredentials.Credentials.SharedSecret.IssuerSecret =“xAWjynZU8AhbjcSyzSgUmRxIk9JNNsQDY6O+CyiXCo0=”;

relayCredentials.Credentials.SimpleWebToken.SimpleWebToken =SharedSecretCredential.ComputeSimpleWebTokenString(“owner”, “xAWjynZU8AhbjcSyzSgUmRxIk9JNNsQDY6O+CyiXCo0=”) ;

var binding = new BasicHttpRelayBinding();

binding.Security.RelayClientAuthenticationType =RelayClientAuthenticationType.RelayAccessToken;

using (var cf = new ChannelFactory<IService1>(binding,new EndpointAddress(ServiceBusEnvironment.CreateServiceUri(“https”, “testServer”, “Service1”))))

{

cf.Endpoint.Behaviors.Add(relayCredentials);

      var ch = cf.CreateChannel();

      Console.WriteLine(ch.GetData());

      Console.ReadKey();

}

}

}

}

}

To run, first run the server on the server machine, that will host it and bind with service bus endpoint, next you run the client code that will communicate with Service bus endpoint and do the magic.

Here it goes, i have shared this code as i made it happen after lot of brain storming, head banging to laptop screen, google surfing, copy pasting, trying this and that.. and at last, it worked. And i was able to call the service behind the firewall through Service Bus Relay.

Windows Azure

Windows azure in simple words is a hosting platform by Microsoft. Microsoft provides its own dataware houses to provide scabale and efficient platform to host applications and services.

Windows Azure™ is a cloud services operating system that serves as the development, service hosting and service management environment for the Windows Azure platform. Windows Azure provides developers with on-demand compute and storage to host, scale, and manage web applications on the internet through Microsoft® datacenters.

Windows Azure is a flexible platform that supports multiple languages and integrates with your existing on-premises environment. To build applications and services on Windows Azure, developers can use their existing Microsoft Visual Studio® expertise. In addition, Windows Azure supports popular standards, protocols and languages including SOAP, REST, XML, Java, PHP and Ruby. Windows Azure is now commercially available in 40 countries.

Application Scenarios:

Windows Azure is a service that allows developers to run applications and store data on servers owned and operated by Microsoft. These cloud applications can be targeted at businesses, consumers or both. Some examples are:
•Enterprises that use Windows Azure to run their own line-of-business, batch processing or large-volume computations.
•An independent software vendor (ISV) that creates a SaaS application targeted towards business users.
•Perform large-volume storage, batch processing, intense or large-volume computations
•An ISV that creates a SaaS application targeted towards consumers.

Benefits:
•Agility: Take advantage of development tools, automated service management and global datacenter presence to respond faster to customer needs, focus on your competitive differentiators, and reach new markets.
•Efficiency: Windows Azure improves productivity and increases operational efficiency by lowering up-front capital costs. Customers and partners can realize a reduction in Total Cost of Operations of some workloads by up to 30 – 40% over a 3 year period . The consumption based pricing, packages and discounts for partners lower the barrier to entry for cloud services adoption and ensure a predictable IT spend. •Focus: Focus on delivering services and value to your customers – and not on managing technology infrastructure. Windows Azure enables you to spend less time on operational hurdles and more time focusing on your competitive differentiators.
•Simplicity: Utilize your existing skills in familiar languages such as .NET, Java and PHP to create and manage web applications and services.
•Trustworthy: Enterprise class service backed by a reliable service level agreements and a rich online services experience.

Windows Azure Training Session at LMKR

Windows Azure™ is a cloud services operating system that serves as the development, service hosting and service management environment for the Windows Azure platform. Windows Azure provides developers with on-demand compute and storage to host, scale, and manage web applications on the internet through Microsoft® datacenters.

Windows Azure is a flexible platform that supports multiple languages and integrates with your existing on-premises environment. To build applications and services on Windows Azure, developers can use their existing Microsoft Visual Studio® expertise. In addition, Windows Azure supports popular standards, protocols and languages including SOAP, REST, XML, Java, PHP and Ruby. Windows Azure is now commercially available in 40 countries.

I was recently called by Microsoft Innovation center to speak at LMKR (LandMark Resources), an international software company involved in developing and implementing solutions for storage, processing, simulation and integration of sub-surface data. Held on 8th April 2011.

It was an interesting session for me and the audience I believe. I have seen much interest in the rising hosting technology that was a positive sign. I thoroughly enjoyed it.

LMKR Training Session

LMKR Training Session