Showing posts with label Azure. Show all posts
Showing posts with label Azure. Show all posts

Monday, November 18, 2013

Team Foundation Services is now Visual Studio Online

Microsoft officially launched Visual Studio Online (Formerly Team Foundation Services) last week.  The announcement came with news of many added features and benefits.  Here is an overview of the announcement:

Pricing

The good news is that if you have MSDN, you are most likely going to still not be charged for day-to-day usage. The bad news is that if you have product owner or product manager roles our your team and want them to use VSO for backlog interaction, etc.  They will now need to pay a membership fee.  The MSDN license that allows that access free, is the Ultimate level, which is the most expensive MSDN package there is.   This is going to cost at least $45 monthly for these employees (of course depending upon their role in your organization).  You can find the breakdown of pricing levels here.  The other financial consideration is that you will be charged for build time on any build and deploy jobs.  This is basically going to cost a couple of pennies per minute every time you do a CI style build. I did some investigation and found out that this does include publish time. In our world, that is roughly 65% of the time the build job is running.  So, you will pay the going rate while your build is being uploaded and deployed to the Azure instances for which you are already paying.

Link VSO with Azure

Link your VSO account to your Azure account and have a single portal for managing them both.  Very handy.  Details here.

Monaco

Monaco is a new development service specifically designed for building and maintaining Windows Azure Websites. With Monaco, developers have a lightweight free companion to the Visual Studio desktop IDE that is accessible from any device on any platform. Monaco is a rich, browser based, code focused development environment optimized for the Windows Azure platform, making it easy to start building and maintaining applications for the cloud.  Here are some cool videos on Channel9

Application Insights


With this “360 degree view” of your application, Application Insights can quickly detect availability and performance problems, alert you, pinpoint their root cause and connect you to rich diagnostic experiences in Visual Studio for diagnosis and repair. It also supports continuous, data-driven improvement of an application. For example it highlights which features are most and least used, where users get “stuck” in an application, where and why exceptions are occurring, which client platforms are being used with which OS versions, and where performance optimizations will make the biggest impact on compute costs.  You can sign up for the free preview here.  Following are some sample screen shots:


Dashboard
Visual Studio Integration

Environment Metrics

Monday, August 26, 2013

Securing a Web API with Windows Azure AD and Katana

I just read through this article doing a walk-through on how to secure your WebAPI with Azure AD using Katana and OWIN.  It lays out all of the benefits of of OWIN and using Katana. 

http://www.cloudidentity.com/blog/2013/07/23/securing-a-web-api-with-windows-azure-ad-and-katana/

Worth the read.

Monday, August 12, 2013

Windows Azure Notification Hubs

Windows Azure Notification Hubs was just released for general availability.  These hubs help mobile app developers deliver large numbers of push notifications to mobile users on a wide range of platform.Windows Azure Notification Hubs makes sending push notifications through multiple notification services achievable with just a few lines of code.  Today, apps like the Bing News for Windows 8 are using notification to send millions of push notifications to inform users of the latest breaking news. 

This doesn't replace Windows Azure Mobile Services, which  also supports push notifications. The table below explains the differences.   In short, Mobile Services is best used for communicating to a single user whereas Notification Hubs is best used for communicating to many users simultaneously.


Mobile Services
Notification Hubs
MPNS, WNS, APNS, and GCM support
Yes
Yes
Turnkey event-triggered push
Yes
No
Device registration management
No
Yes
Interest tags for routing messages to a subset of users
No
Yes
Templates for formatting messages to user preferences including language
No
Yes
Broadcast to >1 million devices at once within minutes
No
Yes 

Check out Scott Gu's post for more details.

Thursday, May 16, 2013

IIS Issue - Ignoring default document

We were having some issues trying to get an Azure app to show the proper page by default when hitting the root domain.  We flailed around for a while and eventually someone found out that there is a known issue in Windows 7 Service Pack 1 that causes the Extensionless URL feature to interfere with the way ASP.NET parses URLs that would normally be handled by the Default Document setting.  This causes redirection to the Forms Authentication login page instead of the Default Document when the url is pointing to the root of the website.  The solution is to rewrite any requests made to the root of the website to a url that explicitly references the "defaultDocument".

Do this in the global.asx:
void Application_BeginRequest(object sender, EventArgs e)
{
    if (Request.AppRelativeCurrentExecutionFilePath == "~/")
    {
        // Get the defaultDocument filename from web.config.
        System.Xml.Linq.XDocument xDoc = 
            System.Xml.Linq.XDocument.Load(HttpContext.Current.Server.MapPath("~/Web.config"));

        string defaultDocumentName = 
            xDoc.Element("configuration")
            .Element("system.webServer")
            .Element("defaultDocument")
            .Element("files")
            .Element("add").Attribute("value").Value;

        // Rewrite the url.
        HttpContext.Current.RewritePath(defaultDocumentName);
    }
}

Hope this saves someone else some time.

Wednesday, May 8, 2013

Federation Architecture

While creating web applications with large, multi-tenant data sets, it becomes an immediate architectural need to plan for scaling data storage.  This plan cannot be an afterthought, but must be a paramount consideration at the outset of the project.  Performance and scalability issues on the data layer can create an array of issues that each manifests themselves as a poor user experience, and ultimately damage the brand of the application.  One such approach for handling this need is to scale horizontally using a technique known as 'Sharding'.  Sharding allows one to separate the rows of storage across multiple physical databases, which enables much scalability and should result in better performance on the data layer.  This process enables one to plan for scale, build for speed and control capacity.  Sharding also allows the operational aspect of the web application to scale, increase performance, and add additional capacity dynamically to the data layer with no downtime, which is vital to a thriving user base.

Federations are individual data partitions, which have their individual scheme centrally managed by a single distribution (or federation) scheme.  That scheme defines and controls the single keying mechanism for cross-partition distribution.  While a handful of data types are acceptable for the distribution key, I like the simplicity of a bigint as defining key (of any kind actually).

The individual partitions are members of the federation, each with their own schema.  As such, they are responsible for any inclusive subset of the values in a federated table covered by the data type of the federation distribution key.  The individual can be responsible for all of the values or a range of the values giving the architecture the ability to scale dynamically to match the current need.   While each partition has its own schema, the table keys correspond to the federation scheme. A federation member may also contain tables that are not part of the federation, known as reference tables.  Reference tables can be including in results that along with federation aware data.  It is important to note that each partition controls its own schema.  As such, it may or may not match the schema of other member partitions.

When building a federation plan, a paramount decision to make is deciding value upon which value to federate. I think the best practice may be to use a value that is meaningful to the data separation you are trying to achieve. In my world, the thing that makes the most sense is the customer or tenant identifier.  This gives us the ability to centrally reference all data for querying, yet provide each customer with what amounts to a singularly responsible and sovereign data set.

While sharding is a great solution for these types of application, it is important to understand the complexity that accompanies the sharding process. Depending on the individual implementation flavor, sharding may developers handle rollbacks, constraints, and referential integrity across tables when historically those items have been handled by the database itself.   It also makes joins, global searches and other high-level insight more difficult.  Even knowing the trade-offs being made for the ability to scale data, it is hard to argue a properly executed sharding strategy for serving multi-tenant data in a web-mobile application world.  The process checks all of the boxes required by the various user stories and operational concerns.

Sharding is a good example of a core belief of mine; It really should not matter how difficult or easy, how fancy or how simple a given technique or design is. The right answer should be the right answer.  You should not over-design because one thing seems too simple, nor should you under-design because it seems too hard.  The entirety of the platform truth should become self-evident and then pursued as the goal.

Friday, February 15, 2013

Azure Media Services

Microsoft has added more offerings to the already large catalog of Azure services.  Recently, they announced the launch of Azure Media Services which allows you to upload, encode and deliver streaming media content to a vast array of consuming devices.  Historically, we have had to partner with other vendors to provide the streaming media while leveraging Azure services to deliver our applications.  With this offering, it seems that you could simply partner with Microsoft and allow Azure to fulfill all of the needs you may have to deliver your assets to virtually any device.  While this offering is fairly new, I have gathered the following information.

Answering the Common Questions


1. Protection.  One of the first items people always bring up when building a streaming solution is the protection of assets.  Azure allows you to store and deliver content in a secure fashion by leveraging either Microsoft PlayReady DRM or Apple AES.  

2. User experience.  We are all concerned about ensuring that our content is seen in the best light possible at all times.  Azure Media Services offers the ability to not only encode your media into a large range of standard codecs and adaptive bitrate formats, but to also create an adaptive delivery experience by allowing on-the-fly format conversion.  Your content can be streamed to Windows 8 applications, Windows Phone applications, Browsers (via Silverlight), iOS devices and android devices which covers a large majority of consumer need.

3. Development.  Generally, your streaming partner provides some flavor of SDK for interacting with their service as part of your application development and deployment.  One of the huge by-products by partnering with Azure for this type of application is that their services are native and integrated into the rest of your Azure platform. You can program Media Services using the OData-based REST APIs. You can build an application making REST API calls to Media Services from .NET languages or other programming languages. You can easily deliver your content to devices such as connected TVs, set-top boxes, Blu-Ray players, OTT TV boxes, and mobile devices that have a custom application development framework and a custom media pipeline.  Microsoft provides porting kits (for a fee) that allow you to code to the smooth streaming platform.

4. Ads.  Yes, you can integrate ads into your product using overlays.  This allows you to have both paid and free versions of your application if so desired.

At a glance, this seems pretty powerful.  I am going to dive in and investigate at a more detailed level to see what kind of possibilities this may offer moving forward.

Wednesday, December 5, 2012

Windows Azure Mobile Services

The Azure Mobile Services platform has some great new functionality that works toward making this a total solution for a mobile / web application hosting environment.  Some of the new features include:
  • iOS support – enabling you to connect iPhone and iPad apps to mobile services
  • iOS Push Notifications via APNS (Apple Push Notification Services)
  • Facebook, Twitter, and Google authentication support with mobile services
  • Blob, Table, Queue, and Service Bus support from within your mobile service
  • Sending emails from your mobile service (in partnership with SendGrid)
  • Sending SMS messages from your mobile service (in partnership with Twilio)
  • Ability to deploy mobile services in the west US region
Scott Gu had an article on his blog this morning outlining the expanded support for iOS on the Windows Azure Mobile Services platform. This post runs through how to create a web service that sends push notifications to iOS devices using a native Objective-C SDK within Azure.

This will go a long way toward making Azure the gold standard platform for hosting a web application that interacts with all devices.  By combining this technology with the Windows 8 mobile platform to leverage your Azure-hosted RESTful services, you are able to offer a wide range of device support with a large amount of shared infrastructure and service instance.

If you would like to walk through a tutorial using the push notifications, Microsoft has published one that covers all of the basics. You can view the first tutorial here and follow it up with this one

Thursday, September 13, 2012

Windows Azure Mobile Services

On August 28th, Microsoft announced an addition to the Azure platform, Windows Azure Mobile Services.  The capabilities seem very powerful and target easy development and deployment of mobile applications with a cloud-based backend service hosted on Azure.  While this is targeted at Windows 8 applications exclusively, it appears to scale very well into using a mobile-first approach to all of your Windows 8 applications, desktop or mobile.  The backend framework allows for direct access to SQLAzure data via the mobile service.  In fact, when you create a Windows Azure Mobile Service, it is automatically associated with a SQL Database inside Windows Azure.  This all happens without creating any custom server code.   The management portal includes the ability to create new tables, control access, view data and other administrative items.  By leveraging this infrastructure, developers can connect directly to their cloud-based data very easily without having any insight into the server side code.  The data can be automatically accessed and stored via a secure RESTful interface.  This allows a client side developer to quickly and easily connect any Windows 8 application to the new mobile platform and its data.

Here is a code snippet showing the mechanism for directly consuming mobile cloud based data.  The native interface supports LINQ based queries of POCO objects (strongly typed) via the RESTful interface.  This code will populate a presentation layer asynchronously without creating ANY server side code to handle it.

private void RefreshTodoItems()
{
    items = App.MobileService.GetTable< TodoItem >()
       .Where(todoItem => todoItem.Complete == false)
       .ToCollectionView();

    ListItems.ItemsSource = items;
}

At this point, you have built a data driven SOA that is able to be consumed directly by any windows 8 presentation layer.

Other items that are directly supported via the Azure Mobile Services are: push notifications, user authentication and  paged queries -- all with the native services provided.  It seems to be quite easy to directly connect your Windows 8 application to the mobile services in Azure.  The upside being that it makes developing a Windows 8 client based on a cloud solution very quick and easy.  The unanswered question is still how easily you can use this to consume data in cloud style without using a Windows 8 application.  It appears that it would be possible to directly hit this service from any application able to read JSON from a REST service, but all of the supporting documentation is focused on a Windows 8 client.  Either way, this is an exciting addition that should be investigated by those of us using Azure. 

Monday, August 13, 2012

Multi-tenant WCF Services

Hosting a multi-tenant application using WCF
While doing some long-term architecture design, the task was given to work through a cloud-based application.  Our business requirements have resulted in the need for a multi-tenant application built on WCF services that can share physical instances for multiple tenants. The first thing that jumps out in this framework for me is that these services must not contain state level variables that would directly relate to any single tenant. In this model, for instance, a BLL type service should not contain a static list of 'droplist' items to be consumed by the software unless the listing was tenant/customer agnostic. This breakdown gives us the ability to scale at any point in the SOA, based on load or any other need that may present itself. The gain is that you are not locked into a 1:1 tenant:service instance relationship which allows for more host cost effective scaling. In our model, based on the type of data stored, we have decided to go with a separate catalog for each tenant. This point works for our model and while I know there are other models that work effectively, this is really not the target of the current post.

Building the flow and responsibilities 
The first obstacle presented was how to point a tenant at the corresponding catalog without having the SOA be inherently aware of the tenant. For our model, we have the user authenticating against a centralized database and service purposed exclusively for housing tenant information. This enables us to assume that a client will be self-aware and could be provided with their tenant information to some degree prior to engaging the full SOA of the application. The idea being that if we can have the service dynamically recognize the tenant based on the tenant self-identifying at the time of messaging, we can achieve a loosely coupled environment for services to perform with a disregard for the actual tenant entity.

Communicating tenant information
While thinking through a means to provide tenant information to the services, there are a couple of possibilities that come to mind. One could simply provide all of the required information as parameters to each service call.  Would it work? Yes. Is it a good idea? No. There are many reasons this is not a good solution. One concern is the added difficulty each client application would encounter trying to consume the SOA. Plus, the SOA would be confusing, difficult to implement and not very readable as a programmer. To me, building your SOA must always consider the consuming applications and the ease with which the services can be consumed as a high priority. Those alone point us directly to the messaging interface for the service. My initial thought was to create custom incoming and outgoing message header properties to allow C# windows clients to attach the properties directly via their client proxy and then dynamically read them out in the service layer. This allows all additional difficulty to be encapsulated within the client proxy/channel factory classes. This also allows non-windows users to dynamically build message headers and attach them to the calls coming into WCF while allowing the service to leverage a single implementation to pull the information out of the message. I needed to create a proof of concept application to illustrate this. I was wrapped up in another project at the time, so ToddM took the project on and delivered an illustrative project. (Thanks, Todd). An overview of the successful prototype is as follows. First, you have to attach the outgoing behavior message header at the channel factory level in C#. This requires the creation of CustomServiceOutgoingBehvaior and CustomServiceIncomingBehvaior classes based on IEndpointBehavior and Attribute, IServiceBehavior respectively. These are then attached to the DataChannel and inspected on either side of the communication. In an effort to make this post shorter and more readable, I have removed code that doesn't directly support the main idea. To be clear, these snippets on their own are not enough.

public class DatabaseInfo
{
  public String Catalog { get; set; }
  public String Instance{ get; set; }
}
public static class Tenant
{
    public static String TenantID { get; set; }
    public static String AuthenticatedUser { get; set; }
}

public class CustomClientOutgoingBehvaior : IEndpointBehavior
{
   void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint endpoint,
              ClientRuntime clientRuntime)
    {
        clientRuntime.MessageInspectors.Add(new CustomClientOutgoingMessageInspector());
    }

}

public class CustomServiceOutgoingBehvaior : IEndpointBehavior
{
    DatabaseInfo info = null;

    public CustomServiceOutgoingBehvaior(DatabaseInfo info)
    {
        this.info = info;
    }

  
    void IEndpointBehavior.ApplyClientBehavior(ServiceEndpoint 
              endpoint, ClientRuntime clientRuntime)
    {
        clientRuntime.MessageInspectors.Add(new CustomServiceOutgoingMessageInspector(info));
    }
}

public class CustomServiceIncomingBehavior : Attribute, IServiceBehavior
{
    void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription
           serviceDescription, ServiceHostBase serviceHostBase)
    {
        foreach (ChannelDispatcher channelDispatcher in 
         serviceHostBase.ChannelDispatchers)
        {
            foreach (var endpointDispatcher in channelDispatcher.Endpoints)
            {
                endpointDispatcher.DispatchRuntime.
                     MessageInspectors.Add(new 
                     CustomServiceIncomingMessageInspector());
            }
        }
    }
}
public class CustomClientOutgoingMessageInspector : IClientMessageInspector
{
   object IClientMessageInspector.BeforeSendRequest(ref Message 
     request, IClientChannel channel)
    {
        var messageHeader = new MessageHeader<String>(Tenant.TenantID);
        var untypedMessageHeader = 
               messageHeader.GetUntypedHeader("TenantID", "Namespace.Shared");
        request.Headers.Add(untypedMessageHeader);

        messageHeader = new MessageHeader<String>(Tenant.AuthenticatedUser);
        untypedMessageHeader = 
              messageHeader.GetUntypedHeader("AuthenticatedUser", "Namespace.Shared");
        request.Headers.Add(untypedMessageHeader);

        return null;
    }
}

public class CustomServiceOutgoingMessageInspector : IClientMessageInspector
{
    public DatabaseInfo DatabaseInfo { get; set; }

    public CustomServiceOutgoingMessageInspector(DatabaseInfo info)
    {
        DatabaseInfo = info;
    }
  
    object IClientMessageInspector.BeforeSendRequest(ref Message request, IClientChannel channel)
    {
        if (DatabaseInfo == null)
            return null;

        var messageHeader = new MessageHeader<String>(DatabaseInfo.Catalog);
        var untypedMessageHeader = 
            messageHeader.GetUntypedHeader("Catalog", "Namespace.Shared");
        request.Headers.Add(untypedMessageHeader);

        messageHeader = new MessageHeader<String>(DatabaseInfo.Instance);
        untypedMessageHeader = 
            messageHeader.GetUntypedHeader("Instance", "Namespace.Shared");
        request.Headers.Add(untypedMessageHeader);

        return null;
    }
}
 
Then, with a simple function added to a base class for your WCF services, you will be able to pull this information back out as follows:

protected Tuple<DatabaseInfo, Tenent> GetInfoFromHeader()
{
    DatabaseInfo dbInfo = new DatabaseInfo();
    Tenant tenantInfo = new Tenant();

    Int32 i = OperationContext.Current.IncomingMessageHeaders.FindHeader("Catalog", "Namespace.Shared");

    if (i != -1)
        dbInfo.Catalog = OperationContext.Current.IncomingMessageHeaders.GetHeader<String>(i);

    i = OperationContext.Current.IncomingMessageHeaders.FindHeader("Instance", "Namespace.Shared");

    if (i != -1)
        dbInfo.Instance = OperationContext.Current.IncomingMessageHeaders.GetHeader<String>(i);

    i = OperationContext.Current.IncomingMessageHeaders.FindHeader("TenantID", "Namespace.Shared");

    if (i != -1)
        tenantInfo.TenantID = OperationContext.Current.IncomingMessageHeaders.GetHeade<String>(i);

    i = OperationContext.Current.IncomingMessageHeaders.FindHeader("AuthenticatedUser", "Namespace.Shared");

    if (i != -1)
        tenantInfo.AuthenticatedUser = OperationContext.Current.IncomingMessageHeaders.GetHeader<String>(i);


    return new Tuple<DatabaseInfo, Tenent>(dbInfo,tenantInfo);
}
 
At this point, you will be able to pull out information from the message header and perform many routines based on a tenant entity without adding state to the server. With this information, you can build connection strings for each DAL method pointing to the correct catalog and instance based on tenant.  You can also perform user security functions based on the AuthenticatedUser passed from the client.  As you can see, this is very flexible and would scale out to any values that needed to be communicated along with the messages to the service.

Wednesday, April 4, 2012

SQL Azure Backup / Restore

After a coworker and I spent the better part of a day trying to get a local database (with data) deployed and running on our SQL Azure instance, I finally found a tool that seemed to make this task at least attainable.  SQLAzureMW has a wizard that automates some of the very manual tasks required to manage a SQLAzure instance.  I used the sync data from local to azure instance options through the wizard, and after some trial and error, it did actually work.    Although, it is no replacement for actually having a full suite of smss tools....  hello....  But, I digress.


I found that in my case anyway, it was an easier task to simply create a new catalog each time instead of trying to sync the data or create import scripts.  After finishing that, the database was created, but I couldn't actually log in to it or use it from my app.  So, we realized that you have to implicitly grant all permissions using a sql on your new catalog.  There is no tool for user security management on SQL Azure.  In order to speed things along, I wrote this quick little statement:


DECLARE @userName varchar(100);  
DECLARE @loginName varchar(100);  
SET @userName='myNewUser';  
SET @loginName='myExistingLogin';  
SELECT 'DROP USER ['+@userName+'] ;'  
UNION ALL SELECT 'CREATE USER ['+@userName+'] FOR LOGIN ['+@loginName+']
   WITH DEFAULT_SCHEMA=[dbo]'  
UNION ALL  
SELECT 'GRANT ALTER, DELETE, REFERENCES, CONTROL, INSERT, SELECT, UPDATE,
  VIEW DEFINITION ON [dbo].['+name+'] TO USER ['+@userName+'] ; GO'  
from sys.tables  
UNION ALL SELECT 'GRANT EXECUTE, ALTER, VIEW DEFINITION ON [dbo].['+ name+']
  TO USER ['+@userName+']; GO'  
FROM sys.procedures;    

At this point, we were able to run against our newly created catalog and so far, it has been working well. We have signed up for a beta group with Microsoft to use what they told us were backup and restore tools on azure.  Hopefully, that will be a real solution.  But in the meantime, this worked pretty well.