Connect:    



Event Calendar

Some useful links

Online Courses

Articles


A software architect, Azure expert, and former Microsoft evangelist, Mike Benkovich dedicates huge amounts of his time to helping his fellow developers and burgeoning programmers learn about new technologies and platforms. Mike’s website equips developers with tips and resources to help them get to grips with technologies including cloud, data and devices, and he produces online courses covering areas like Azure enterprise development and serverless computing. Mike is also a chronic sharer of puns, so head over to his Twitter feed if you’re after a laugh (or a groan).

BenkoBLOG by Tags


Blog Roll...
Conferences
Regional User Groups

Blog

Reviewing Julie Ng's CI/CD Checklist

@MikeBenkovich 08/07/2023

I recommended a video by Julie Ng, who has a blog and a video thing on YouTube you can subscribe to that provides some great information about containerization, kubernetes and Azure. The video is CI/CD Review - How DevOps in Real Life & Mature Organizations works | Julie Ng

Here's some tools and links from Julie's talk


Agile DevOps West 2022

@MikeBenkovich 06/16/2022

This week in Las Vegas at the Agile DevOps West conference I'm presenting the session Permit to Cloud - Land with Confidence in Azure!

We'll talk about a lot fo things, but the goal is to provide an introduction to how to get started with Azure in a way that will help ensure continued success in taking advantage of the promises the cloud offers. For the code and demos I've published them to https://github.com/benkotips/askdad - Check it out!


DevUp 2022

@MikeBenkovich 06/08/2022

Guess What? In person events are a thing again,  and I'm back on the road. It's great to be back to St. Louis, this week I'm delivering sessions at DevUp on how to work with Azure and Infrastructure as Code topics. 

  • Permit to Cloud : Land with Confidence in Azure
  • Cosmos DB Performance Tuning
  • Infrastructure as Code Bake-off : Comparing ARM, Bicep, Terraform and Pulumi

The link to the code is on GitHub at https://github.com/mbenko/du22-ptc - Check it out!


Azure Office Hour Fridays

@MikeBenkovich 05/04/2021

Thinking about going to Cloud? I've been consulting around Azure for the last 8 years since I left Microsoft where I helped launch it in 2009. I want to offer my support, so I'm starting a thing called Azure Office Hours on Fridays, where anyone can block out 15 minutes to chat about anything Azure.

  1. Find a time that works - https://bit.ly/BnkAzHrs 
  2. Let me know what you want to talk about
  3. Let's chat! 

I speak at conferences and have LinkedIn learning courses on Azure and DevOps including templating, compute, storage, messaging, networking and governance topics.

My calendar is open. Let's connect!


Using Cosmos DB for my Blog

@MikeBenkovich 04/30/2021

Have you thought of using new/different technologies to explore the impact of using new tools? I'm presenting a new session at Minnesota Developer Conference on Tuesday 5/4/2021 (Star Wars day) that will explore the technology and implementation details to make this type of implementation work.

Check it out!

Cosmos Tools for the Relational Developer

Tuesday 5/4 at 11:00 am - MDC 2021 | Minnesota Developers Conference (mndevconf.com)

Understanding how your data works is crucial to taking advantage of the capabilities and power of Cosmos DB, from setting up and migrating data, to querying to understanding performance consequences of data manipulation. These tasks become easier thanks to a growing ecosystem of tools around the Cosmos DB platform. In this session we'll look at how Cosmos DB tools available from Microsoft and 3rd parties make it easy to make the transition from the relational to Cosmos.

The topics we'll cover include:

  • Why Azure Cosmos DB
  • Provisioning a Cosmos DB from the Azure Portal
  • Code patterns for working with Cosmos
  • Data Migration
  • Data Modeling and strategies for performance and cost optimization

Some reference links:

Enjoy!


5 Minutes to Code

@MikeBenkovich 02/15/2020

I'm working thru an idea for a video series that I call "5 Minutes to Code", where I would record some short videos that show how to accomplish a concept, procedure or task related to working with code. The goal is to deliver on a regular cadence some content that developers can use to learn how to do something. Lately I've been working with Azure as a cloud engineer working on infrastructure (like ARM and Terraform), delivery (like Azure DevOps and from developer tools), and coding (like .NET Core and web development). I have created a new page on my site where I'll publish a list of links to these, and this will give me the chance to work on my html and JavaScript skills.

Enjoy!


This year at Build 2018 - Azure for Enterprise Developers

@MikeBenkovich 05/05/2018

At this year's Microsoft BUILD Conference I was able to get a couple sessions to talk about the Enterprise Developer's journey to the Cloud. The sessions will be on Monday at 5:00 pm and Tuesday at 5:00 pm in Theater 4 on the Expo Hall Theater 4.

In it I'm going to share some exciting advancements in the tools we use every day to create great software, but especially the features that make those applications cloud aware! Not only can you create an publish to Azure but now you can also work with the settings and create templates to use for future deployments as well. The new Resource Group project enables the creation of complex infrastructure deployments that include not just the web hosting services but also analytics and monitoring capabilities as well as alerts when things go wrong.

If you're at Build stop by and let's chat about how you can make your team not just cloud aware, but Ready for the Enterprise Cloud! If you can't make it, I'm basing the talk on some course I'm developing for LinkedIn Learning called Azure for the Enterprise Developer. You can check those out online, they include:

Outside of that, I'll be hanging out at Build and tweeting about what's new and getting ready for the next roadshow. See you on the road!


Deploying a Shared Dashboard in Azure

@MikeBenkovich 04/26/2018

Getting an application operational depends on making sure that it can run after the developer has left the room. In the enterprise we have teams of people of focus on that and will go to great lengths to make sure the team that runs the application that was built is solid and predictable. One of the challenges with the cloud is getting an operations team that has been trained to be cloud experts.

To alleviate that problem, Azure supports the dashboard you see in http://portal.azure.com as a shareable resource just like any other service you provision. You can create and customize dashboards by using the portal and pinning tiles that are relevant to your application. When you publish the dashboard you can share it with other teams that have access to Azure, including the operations team.

That is why I created a starter dashboard ARM template you can use to make your deployments more operational. It includes a couple tiles, including a resource group tile and a markdown tile with some instructions on how to customize and share the dashboard with others on your team.

Click the link below to provision it from the Azure portal. I’ve got a pull request to add it to the azure starter template library but until then you can get it from a storage account I’ve uploaded it to. Click the link below to deploy a starter dashboard to your Azure subscription for resource group.

Technorati Tags: ,,,

Azure for the Enterprise Developer

@MikeBenkovich 04/25/2018

A picture is worth a thousand words and in the same way deploying a complex infrastructure with a thousand words takes a special skill to be able to do that. Wouldn’t it be great if we could deploy the picture instead? In the time I’ve been working with and evangelizing Azure since before it was publicly released, I’ve seen a lot of changes and ten years is a long time in the cloud! In 2014 Microsoft introduced the Azure Resource Manager (ARM) which provides a powerful way to orchestrate the creation of services in the cloud. They also introduced ARM templates, which is like a markup language that provides a picture instead of code. I’m working on a series of courses with LinkedIn Learning that share the journey of going to the cloud for the modern enterprise. We explore the path and the tools for going from being just cloud aware (it runs in the cloud) to being optimized, invested and finally ready for the enterprise.

This is a work in progress, but links to the first few courses are below. I’ll update the list as more are ready!


rebuild17 Resources

@MikeBenkovich 05/29/2017

As promised last week I updated the slides with the session that the content was drawn from. Here is the consolidated list of sessions with deeper dives into the topics from Build:

  • B8020 - Cognitive Services & Computer Vision Made Easy
  • B8049 - Enable intelligence with Azure IoT Edge
  • B8096 - Windows Template Studio
  • B8100 - What's New and Coming in Windows UI Platform
  • B8001 - Three Runtimes One Standard .NET Standard
  • B8048 - Introducing .NET Core 2.0
  • B8027 - Azure Debugging & Snappoints
  • B8039 - Design for Serverless Success
  • B8061 - How to build serverless business applications
  • B8099 - Xamarin Tools
  • B8103 - The Future of Xamarin Development
  • B8072 - Overview of Mobile Center

My GitHub repo for the event - http://github.com/mbenko/rebuild17. Other links from the event include:


Re-BUILD 2017, bringing the best of BUILD conference to cities near you

@MikeBenkovich 05/14/2017

Re-BUILD 2017 Roadshow

The “re-BUILD 2017 Roadshow” brings the best of the Build conference to cities across the US. A half day developer focused event in partnership with User Groups and Microsoft Partners will deliver a half day msdn-event style experience. There will be 3  sessions on Build Highlights, Going Serverless with Azure Functions, and Mobile Center, the next generation of HockeyApp. A HackFest over lunch will cover ad-hoc topics by community leaders and MVP’s to share their favorite thing from Build.

The schedule typically includes:

  • Build 2017 Productivity Features you never knew you had
  • Going Serverless with Azure Functions
  • Exploring Mobile Center
  • Pizza and Hackfest

The scheduled cities are listed below with more coming soon!

We'll see you on the road with re-BUILD 2017 Roadshow!


VS 2017 Launch Live Notes

@MikeBenkovich 03/07/2017

Watching the live stream of the Visual Studio 2017 launch and 20 year anniversary party…thought I’d capture some of the notes of what’s going on and share the fun.

Visual Studio 2017 release

Developer Productivity - Kasey Uhlenhuth

  • Live Unit Tests
  • Exception helper
  • Find all references
  • New intellitrace tray of options
  • Ctrl+T for goto All
  • Code suggestions
  • Code Config file - map code styles and suggestions for environment
  • Support for tuples on methods
  • Improved refactoring
  • Indent guide visibility to method code is in even if not visible

.NET Core - Beth Massi

  • .net Tools for Core 1.0 in production
  • Migrate/Upgrade to new tools easy
  • Simplified csproj format which is human readable
  • References grouped by type…i.e. nuget refs, project refs, etc.
  • Application Insights
    • New add-in experience
    • Search and graph analytics in VS

Containers Docker - Scott Hanselman

  • Add docker support in VS right click on project
  • Run in docker if selected startup project
  • Debug, edit and volume mapping realtime from vs to docker
  • Publish to Linux docker or windows
  • Automatically references other docker containers dependent on
  • Debug across containers
  • Check out Ref application http://aka.ms/MicroservicesArchitecture

Xamarin : James & Miguel

  • Tizen new OS from Samsung for IoT devices…built on Xamarin Forms
  • Visual Studio for Mac Preview 4
  • New App templates
    • Mobile App added with best practices if checkbox Azure
    • Code for clients
  • Forms Previewer
    • Works if you have JDK 1.8+ on x64 installed (settings?)
  • Improved intellisense
  • Native animations in XAML
  • Forms inspector, when connected tp android emulator
    • Layers
    • Live edit of XAML

VS Mobile Center - Keith

  • http://mobile.azure.com
  • Xamarin Test Cloud
  • Add app…pick type
  • Add nuget & register app
  • Distribute sets up a team of testers/user community for builds
  • Build service
    • Pick sln
    • Provisioning profile
    • Certificate for signed builds
    • Trigger
  • Test service …
    • run automated UI tests
    • See devices tested on
  • Crash reporting
    • Usage & crash info
    • Stack dumps grouped by count
  • Analytics
    • Custom events

DevOps - Brian Harry & Donovan Brown

  • Continuous delivery
  • "Shift Right" = delivery improvements, production is part of the plan
  • TFS 2017.1 for on Premise installs
  • http://aka.ms/tfsimportdata
  • Donovan demo - any project, any platform
    • Create project
    • Import Git repo
    • View code
    • Setup build from templates or by scratch
      • Sources - where is repo? In TS or external?
      • Test settings
      • Code Coverage
      • Build agents - windows or linux
      • Search for build task
      • Marketplace for build tasks
      • Create your own extension
      • Variables
      • Create work items on failure
      • Track history/changes to build definitions
    • Release definitions
      • Infrastructure as code
      • Approvers
    • Dashboards
  • Data Migration - Partner with Red Gate
    • In VS RedGate ReadyRoll has tools by default
    • SQL Obj explorer, make changes and save
    • Tell ReadyRoll to refresh with changes, generate migration scripts
      • Add update statements for populating default values on existing data after modification
    • Add database scripts and changes that will happen on the database
    • Add the ReadyRoll task to deploy the database task
  • RedGate included in VS 2017 Enterprise
  • Pluralsight 1yr
  • DevOps Enterprise Accelerator offer

Adding HockeyApp feedback for Android to a Xamarin Forms app

@MikeBenkovich 08/20/2016

I’ve been working on a project that integrates Xamarin with Azure Mobile Apps and uses HockeyApp to distribute the code to test devices. I wanted to add the feature in HockeyApp to allow users to be able to send feedback (including a screenshot) from within the app. On searching for an answer I found a number of good leads but nothing that connected them all so this post is intended to go thru what you need to do to add this feature to your app.

We start with an app that is created from the standard Xamarin Forms template in Visual Studio for cross-platform apps (this assumes you have Visual Studio 2015.3 with the Xamarin tools installed otherwise it will prompt you to add them).

image

The solution will look like this. Note I had to do a little work to use the Shared version of Xamarin forms with XAML in that I replaced the default App.cs file it includes with XAML versions of that and the MainPage.xaml. You can see the completed demo sample on GitHub here

image

To add HockeyApp’s feedback feature to our solution go to https://www.hockeyapp.net/ and sign up to create a new app. After an app has been created you can get the HockeyApp ID and use it in the MainActivity.cs code for the OnCreate() method when the application registers with HockeyApp. The process is fairly straight forward:

  1. Create a new app on HockeyApp (https://support.hockeyapp.net/kb/app-management-2/how-to-create-a-new-app)
  2. Add the HockeyApp component from Xamarin (https://components.xamarin.com/view/hockeyappandroid)
    SNAGHTML4b9e527[4]
  3. In the MainActivity.cs file of the Android project add a function to register HockeyApp with the AppID you created. We will call it from the OnCreate(). 
  4. private void InitializeHockeyApp()
    {
        CrashManager.Register(this, HOCKEYAPP_APPID, new MyCrashManagerListener());
       
        UpdateManager.Register(this, HOCKEYAPP_APPID);
        FeedbackManager.Register(this, HOCKEYAPP_APPID);
        Tracking.StartUsage(this);
       
    }

  5. Add a method to handle the feedback calls in the MainActivity class. In this implementation I’m also capturing a screenshot that can be added to the feedback process if the user chooses.
  6. public void HandleFeedback()
    {
        FeedbackManager.SetActivityForScreenshot(MainActivity.current);
        FeedbackManager.TakeScreenshot(MainActivity.current);

        FeedbackManager.ShowFeedbackActivity(MainActivity.current);
    }

  7. Implement an ISensorEventListener class to handle shake activity. Note that you need to implement both the Java.Lang.Object interface as well as the ISensorEventListener. I added an overloaded constructor to allow me to pass a reference to the MainActivity instance (parent) that uses this to handle sensor activity. We will also handle the 

  8. // --- Implement ISensorEventListener
    public class MyShakeHandler : Java.Lang.Object, ISensorEventListener
    {
        // --- Reference to parent activity
        private MainActivity parent;

        // Handle Shake from - http://stackoverflow.com/questions/23120186/can-xamarin-handle-shake-accelerometer-on-android
        bool hasUpdated = false;

        DateTime lastUpdate;
        float last_x = 0.0f;
        float last_y = 0.0f;
        float last_z = 0.0f;

        const int ShakeDetectionTimeLapse = 250;
        const double ShakeThreshold = 800;

        // --- In constructor set parent
        public MyShakeHandler(Activity context) : base()
        {
            parent = (MainActivity)context;
        }

        public void OnAccuracyChanged(Android.Hardware.Sensor sensor, Android.Hardware.SensorStatus accuracy)
        {
        }

        public void OnSensorChanged(Android.Hardware.SensorEvent e)
        {
            if (e.Sensor.Type == Android.Hardware.SensorType.Accelerometer)
            {
                float x = e.Values[0];
                float y = e.Values[1];
                float z = e.Values[2];

                DateTime curTime = System.DateTime.Now;
                if (hasUpdated == false)
                {
                    hasUpdated = true;
                    lastUpdate = curTime;
                    last_x = x;
                    last_y = y;
                    last_z = z;
                }
                else
                {
                    if ((curTime - lastUpdate).TotalMilliseconds > ShakeDetectionTimeLapse)
                    {
                        float diffTime = (float)(curTime - lastUpdate).TotalMilliseconds;
                        lastUpdate = curTime;
                        float total = x + y + z - last_x - last_y - last_z;
                        float speed = Math.Abs(total) / diffTime * 10000;

                        if (speed > ShakeThreshold)
                        {
                            // --- Call parent's Feedback handler
                            parent.HandleFeedback();
                        }

                        last_x = x;
                        last_y = y;
                        last_z = z;
                    }
                }
            }
        }
    }

  9. In the MainActivity.cs OnCreate() function add code to add an accelerometer sensor recognition. Note that you also have to add usings for Android.Hardware and for HockeyApp.Android. The code for OnCreate() will look like this:
  10.         // --- Add Globals
            public static string HOCKEYAPP_APPID = "<HOCKEYAPP ID>";
            public static Android.App.Activity current;

            protected override void OnCreate (Bundle bundle)
            {
                base.OnCreate (bundle);

                // --- Register this as a listener with the underlying service.
                var sensorManager = GetSystemService(SensorService) as Android.Hardware.SensorManager;
                var sensor = sensorManager.GetDefaultSensor(Android.Hardware.SensorType.Accelerometer);

                current = this;
                sensorManager.RegisterListener(new MyShakeHandler(current), sensor, Android.Hardware.SensorDelay.Normal);
                InitializeHockeyApp();

     

                global::Xamarin.Forms.Forms.Init (this, bundle);
                LoadApplication(new App());
            }

  11. In the AndroidManifest.xml add permissions to the sensors
  12. <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android">
      <uses-sdk android:minSdkVersion="15" />
      <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
      <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
      <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
      <uses-permission android:name="android.permission.INTERNET" />
      <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
      <uses-feature android:name="android.hardware.sensor.accelerometer" android:required="true" />
      <application android:label="xForms-FeedbackDemo"></application>
    </manifest>

  13. In my scenario I also wanted a button on an about page that can be used to trigger the feedback logic from XAML. To make it work with a Shared code project in Xamarin Forms, I defined a DROID compilation definition so I can conditionally work with Android specific code
    image
  14. In the XAML page you want to add a feedback button connect to the MainActivity’s logic. 
  15. using System;
    using Xamarin.Forms;

    #if DROID
    using HockeyApp.Android;
    using XamFormsFeedbackDemo.Droid;
    #endif

    namespace XamFormsFeedbackDemo
    {
        public partial class MainPage : ContentPage
        {
            public MainPage ()
            {
                InitializeComponent ();
            }
            public void btnFeedback(object sender, EventArgs e)
            {
    #if DROID
                FeedbackManager.SetActivityForScreenshot(MainActivity.current);
                FeedbackManager.TakeScreenshot(MainActivity.current);

                FeedbackManager.ShowFeedbackActivity(MainActivity.current);
    #endif
            }
        }
    }

You can download the code from GitHub here.

Happy Coding!


Playing with MSFT Mobile DevOps story end to end

@MikeBenkovich 07/21/2016

Building code is always fun, especially when you get to work with new technologies and cool tools that make our lives as developers easier. One of those concepts that is driving a lot of organizations is that of DevOps, which we will define here as an approach for automating and  connecting work done with released software. In this article I’d like to show how to connect some of the tools available from Microsoft to work with mobile applications. This will include Xamarin, Team Services, HockeyApp and Azure Mobile Apps.

The process flow

  1. Create a Team Project – myXamarinDemo
  2. In Visual Studio create a Xamarin Forms with XAML and PCL project
  3. Add the solution to source control (use GIt and navigate to select the team project you created)
  4. Commit & Sync
  5. In Team Services add a build definition (Xamarin.Android template)
  6. Remove the steps that activate and deactivate the license, then queue a build
  7. In VS droid project add HockeyApp.droid component and code to register app

 

 

DevOps is


Global Azure Bootcamp 2016

@MikeBenkovich 04/20/2016

Just finished with the Global Azure Boot Camp last week, wanted to post links to the deck and to the downloads.


Check out Open Live Writer

@MikeBenkovich 04/19/2016

imageSince Windows 8 came out its been hard to find some tools that used to work so well with previous versions of Windows. One such tool is Live Writer, which was part of Windows Essentials. I came across this a couple weeks ago and wanted to share, I’ve been using it to work with my blogs and you can get it from http://openlivewriter.org/. I’m starting a new blog and will be updating BenkoTIPS to have an aggregated feed of items from historical blogs I’ve worked on. Should be a fun project.

Enjoy!


Get Azure Tools 2.7 for some great new features including the new Cloud Explorer

@MikeBenkovich 08/20/2015

I like to think of myself as an early adopter, but I’m a month behind in getting the latest set of tools for Visual Studio 2015 and Azure. One of the great additions is the Cloud Explorer, a new utility for managing services provisioned in the cloud. These have been well documented by my friend Brady on the  Azure Blog, but one of my favorite things is the ability to filter subscriptions and/or search for a named service. With it I can click the settings icon, pick the subscription I am working with from a checkbox list. I can also specify a different account which might be associated with a different set of subscriptions.

image

Once I’ve specified which subscription I am working with I get a filtered list of services grouped by type. These include things like Storage Accounts, Databases and Web Apps, as well as other services or automation jobs I’ve created. To make it even easier I can search for a specific name of something with the search box!

image

Once you find what you’re looking for the Actions/Properties box at the bottom of the explorer gives you options for that as well, including the ability to see the logs or attach a debugger.

image

You’ll want to try these out, especially if you’re managing a lot of services. Get it today by clicking one of the links below. Enjoy!

Azure SDK 2.7 for .NET [download for VS 2015 | VS 2013]

Technorati Tags: ,


Setting a schema for the database in Azure Mobile Services

@MikeBenkovich 01/12/2015

I’ve been working on a project using Xamarin.Forms and Azure Mobile Services for a while, and one issue I came across that wasn’t entirely clear is how do you work with an existing database, yet support updates to the tables and be able to deploy to different environments (like Test, QA and Prod)? Hopefully I can shed some light with this post.

Azure Mobile Services is a feature rich cloud service that promises to take care of some of the complexities of building connected mobile apps. It supports things like 3rd party federated identity, push notifications, logging and more. With the original node.js release it supported JavaScript configuration for the CRUD operations against a table along with a dynamic schema that adapts to the request received via REST. In the .NET release they replace node.js with the ability to roll your own logic in C# and handle the data interaction with WebAPI type controllers. It requires a bit more work, and handling the database changes can be confusing.

Fortunately I’ve found a couple articles that help illustrate how this is done (on MSDN), but it doesn’t specify how to handle ongoing updates. To make it work for my scenario I either needed a way to support data model changes to a .NET backend mobile service, but have a consistent schema name when I move between environments. In the second article they show how to enable code-migrations, and to replace the default database initializers, by using the NuGet package manager and modifying code in the WebApiConfig.cs file. The steps were:

  1. Use NuGet Package Manager to Enable-Migrations
  2. Add a starting migration
  3. Update the WebApiConfig.cs file to use a DbMigrator to update the context instead of calling the default initializer

    public
    static class WebApiConfig
    {
    public static void Register()
    {
    // Use this class to set configuration options for your mobile service
    ConfigOptions options = new ConfigOptions();

    // Use this class to set WebAPI configuration options
    HttpConfiguration config = ServiceConfig.Initialize(new ConfigBuilder(options));

    // *** BENKO: Enable database migrations for the service
    //Database.SetInitializer(new MobileServiceInitializer());
    var migrator = new DbMigrator(new Configuration());
    migrator.Update();
    }
    }
  4. Test local and confirm it’s working

I added a couple additional changes to set the schema name for my app in the MobileServiceContext.cs file (in the Models folder).


protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
// *** BENKO: This is what sets the schema name to the service name...
string schema = ServiceSettingsDictionary.GetSchemaName();
schema = "mySchema";
if (!string.IsNullOrEmpty(schema))
{
modelBuilder.HasDefaultSchema(schema);
}

modelBuilder.Conventions.Add(
new AttributeToColumnAnnotationConvention<TableColumnAttribute, string>(
"ServiceTableColumn", (property, attributes) => attributes.Single().ColumnType.ToString()));
}

I also need to make sure to create the schema on my database instance in SQL Azure and grant rights to the service user account. You can get the user account using SQL Server Mgmt tool (expand the users of the database node, or by running a SQL Script to select name from the SysLogins table of the master db. Once you have it you will need to create the schema an grant rights to it. Assuming the service user is ABC123Login_myServiceUser, the script looks like this:



create schema mySchema

-- Grant specific access rights to use based on Schema
GRANT
SELECT, INSERT, UPDATE, DELETE,
ALTER, CONTROL, EXECUTE,
REFERENCES, TAKE OWNERSHIP, VIEW DEFINITION
ON SCHEMA::[mySchema]
TO [abcdefghijLogin_democityUser]

When you publish the mobile service it will attempt to update the database using the schema provided. If there are error you can use the service’s logs to figure out what’s missing. By specifying the schema name instead of using the service’s name I’m able to deploy to multiple environments but integrate this data with my other applications.

Happy Coding! (originally posted on www.benkotips.com)

Technorati Tags: ,,,


CloudTip 15-Avoid a gotcha in naming projects with Mobile Services

@MikeBenkovich 12/15/2014

Short Answer – Don’t use special characters in a Mobile Service’s project name when you create it, the local SQL won’t be able to open the database and you may spend a lot of time figuring out why chasing down false leads…

The Long Answer…

In my last role at Microsoft as an Azure Evangelist I posted a series of cloud tips, which were intended to be quick tips for using the latest tools & services. This one is the next in that series, and focuses around some esoteric gotcha’s that come up when you’re following a convention for organizing your solution in Visual Studio. As you probably are aware you can have multiple projects in a solution, and one approach for keeping them organized is to follow a naming standard that uses a dot-syntax to keep related related things in their right spot.

For example if my project is a solution to a to-do list, I might create the solution called “TestData”, and within that solution have a project for the web called “TestData.web” and a shared project called “TestData.shared”. Following this convention it makes sense if I want to add a data service project I might call it “TestData.svc”, right? When I try this out and build it, I was finding an error that took longer to expose than I had planned, and that’s the focus of this post.

image

I started with this solution and added some custom classes to the data tables to work with my TestData and found that I was getting  errors. The Mobile Services project type includes a testing page that allows me to try out the service and test the calls to my data, which is great. But I found that I was getting an error when I was running the project without adding or changing anything…Isn’t the stuff supposed to work “out of the box”? Instead I get the error - “The database name 'TR_TestData_svc]_TodoItems_InsertUpdateDelete' is invalid. Database names must be of the form [<schema_name>.]<object_name>”. What does this mean???

image

Don’t do this…

It looks like something’s not right with EF, so I tried updating my NuGet’s to make sure I have the latest packages…Right click the project explorer and go to the NuGet page and try update packages…this is the wrong thing to do because the template was created using specific versions of specific packages, and while some can be updated others shouldn’t.

This time I get an error that the JWTSecurityTokenHandler is broken. After some digging I found a StackOverflow post that answers this.  In particular I find that EF is unhappy with the latest MobileServices entity versions so in the NuGet Package Manager I need to uninstall the WindowsAzure.MobileServices.Backend packages and install the specific version 1.0.342.

Do this…Don’t name your Mobile Service project with special characters in the name

The problem isn’t with EF or out of date packages, it has to do with the local database name not being recognizable with the dot-syntax naming convention (another StackOverflow post). In the web config you can fix it by removing the period in the names, or you can do what I did which is just recreate the project without the dot name and test to confirm it’s working, and then rename the services project in the solution.

image

And it works! Time to go and write some code.


How to detect an iOS device when working with Xamarin and Visual Studio

@MikeBenkovich 12/02/2014

Originally posted on: http://geekswithblogs.net/benko/archive/2014/12/03/how-to-detect-an-ios-device-when-working-with-xamarin.aspx

Xamarin + WAMS = Happiness (well, most of the time)

imageFirst some background…I spent the last couple months trying to figure out the best approach for cross-platform development stuff. After some research and working thru some POC’s with Apache Cordova, Native and Xamarin we decided to go down the path of Xamarin as the tool of choice. We did this for a few reasons, including that we can use C# for the code, that with Xamarin Forms it supports XAML as our markup which has a native backend for handling responsive design, and because we would like to have one set of code running across the different device platforms, and we can go deep on a platform to light up features as needed. For learning it there’s a nice set of xamples you can start from in GitHub that show working demo apps.

Secondly we’re using Azure Mobile Services (WAMS) with the .NET implementation so we can customize the authentication process to suit our needs (more on that in another post). The Node.js implementation is fast, but it has its limitations when we have multiple environments, need to work with specific 3rd party libraries, and we wanted to be able to debug completely offline. The new generation of WAMS with .NET does this by providing a WebAPI style implementation that lets me run the service locally and have complete control. All is good.

To build for iOS the configuration requires not just Xamarin but also a mac build machine. I went to Best Buy and found a reasonably inexpensive mini device, and with some cable magic I can connect it to a spare monitor and set it up. It takes a bit of configuration and creation of accounts with Apple to get it working as a dev machine, including registering with the developer program and getting a certificate to build with. The documentation on Xamarin’s site is pretty good on this.

All is good, and I’m able to build out the examples and deploy to my Windows Phone and Android devices, but when I try to detect an iPad (attached to my mac-mini build machine) it says no devices are attached.  When I click the drop down list of debug devices it shows the iOS simulator options. I don’t see the iOS device I have attached to my build machine! What to do?

image

Searching the issue finds some ideas, but after an hour or so of restarting Visual Studio, the mac, and reconnecting the build host and then restarting Visual Studio I find that sometimes it sees my device but then quickly switches to the simulator as the only options to test on. I prefer to run on real devices (a result of attempting to use the Android simulators and waiting in vain for them to start), and also I don’t have the monitor hooked up to the mac except when I turn it on to log in. I found this Stack Overflow post which further down had a nugget of info that solved my problem.

In a multi-project solution in Visual Studio the place to look is the configuration manager. Right click on the solution and open it up. Change the iOS project from iPhoneSimulator to iPhone and Bang! your issue is solved.

image 

Now when I look at my targets for the iOS project it shows my device.

image

All is good. Happy Coding!


CloudTip #17-Build Connected Windows 8 Apps with Windows Azure

@MikeBenkovich 07/10/2012

imageYesterday in Dallas we had Scott Guthrie (@ScottGu) and the Azure team put on a great event at the Irving Convention Center to show off what’s new in the Microsoft Cloud story and to dive into getting started with the tools and services that make it work. Chris Koenig did a great job of coordinating the event and Adam Hoffman, Clint Edmonson and Brian Prince all pitched in with sessions about Virtual Machines, Web Sites and how to work with the services.

imageMy talk was on Building Connected Windows 8 Metro applications with Windows Azure, and we showed how to use the Camera UI to upload images to Blob Storage, Geolocation to add a point of interest to a SQL Azure database and then add a pin to a Bing Map, and finally add Notification Services to update the Live Tile. It was a lot of code and I promised to share it here, so if you’re looking for the link to download it is http://aka.ms/dfwWin8Az.

Here are some notes to be able to build out & deploy locally and then migrate the services to Azure…

image- This project is designed to run locally against the Azure Storage Emulator and SQL Express. It can easily be modified to run as a cloud service, see steps below.
- Do a CTRL+SHIFT+F to search for "TODO" to find all the places where you need to personalize settings
- I've included the script MsdnDB.sql which should be run against a local instance of SQL server, or against a cloud instance.
- You should download the Bing Map VSIX installer to add functionality for Metro. Download the latest from Visual Studio Gallery here
    http://visualstudiogallery.msdn.microsoft.com/0c341dfb-4584-4738-949c-daf55b82df58

- I used several packages to enable notifications. These included
    For MyApp  --> PM> Install-Package Windows8.Notifications

    For MySite --> PM> Install-Package WindowsAzure.Notifications

                   PM> Install-Package wnsrecipe

- To deploy to the Cloud
  1. Create an Azure Web Site from the Management console, then download the publish settings from the web site dashbaord
  2. Create a storage account and update the web.config of MySite with appropriate storage credentials
  3. Create a SQL Azure database
  4. Run the create script MsdnDB.SQL (included) against database
  5. Update credentials in web.config of MySite
  6. Change MyApp MainPage.xaml.cs URI's to point to your site instead of localhost:19480
  7. Run the NuGet Packages from Package Manager console
  8. Register your app for notifications on https://manage.dev.live.com/Build
     - update the Package Name reference in Package.appxmanifest
     - Add the SID and Client secret to the SendNotification method in LocationController.cs


Enjoy!
-mike

Digg This

Did you see Windows Phone 8 Preview?

@MikeBenkovich 06/20/2012

It’s been a busy week by anyone’s estimation. We announced new capabilities in Windows Azure, a new Windows 8 Tablet called Surface, and now Windows Phone comes to the front.   Some great stuff has been announced around the future of Windows Phone yesterday. Here’s a summary of the core 8 features which include:image

Multi-core processor support: As reviewers have noted, Windows Phone runs buttery smooth on phones with a single processor. But piggybacking on the Windows core provides support for multiple cores—so we’re ready for whatever hardware makers dream up.

Bigger, sharper screens: Windows Phone 8 supports two new screen resolutions—1280x768 and 1280x720, opening the door to amazing new handsets with high-definition 720p displays.

More flexible storage: Windows Phone 8 supports removable MicroSD cards, so you can stuff your phone with extra photos, music, and whatever else is important to you, and then easily move it all onto your PC.

NFC wireless sharing: If you haven’t heard the term “NFC” yet, I’m betting you soon will. This emerging wireless technology lets phones share things over short distances. In Windows Phone 8, it helps make sharing photos, Office docs, and contact info easier—just tap your phone another NFC-equipped device. How cool is that?

Internet Explorer 10: The next version of Windows Phone comes with the same web browsing engine that’s headed for Window 8 PCs and tablets. IE10 is faster and more secure, with advanced anti-phishing features like SmartScreen Filter to block dangerous websites and malware.

Wallet: Windows Phone 8’s new digital Wallet feature does two great things. It can keep debit and credit cards, coupons, boarding passes, and other important info right at your fingertips. And when paired with a secure SIM from your carrier, you can also pay for things with a tap of your phone at compatible checkout counters.

Better maps and directions: Windows Phone 8 builds in Nokia mapping as part of the platform. Our partnership will provide more detailed maps and turn-by-turn directions in many countries, plus the ability to store maps offline on your phone so you can work with maps without a data connection.

Cooler apps and games: Basing Windows Phone 8 on the Windows core will unleash a new wave of amazing apps and especially games, for reasons

For a more detailed write up check out the blog post here:

http://windowsteamblog.com/windows_phone/b/windowsphone/

You can also check out a recording of the summit here:

http://channel9.msdn.com/Events/Windows-Phone/Summit

Great stuff coming, stay tuned!

-mike

Digg This

CloudTip #16-Meet the new HTML based Windows Azure Management Portal

@MikeBenkovich 06/07/2012

Windows Azure has seen a number of upgrades. The latest announced today, along with a series of events to showcase and explore the features and capabilities of the Microsoft cloud platform (http://aka.ms/MeetAzMB), clearly shows the move towards simplicity, ease of use, and the speed to which you can get started with Azure. While I can’t cover it all in a single post, this is meant as an introduction to the new portal and in future posts I will explore various aspects and features that you can use for building scalable, durable and performant information solutions. A number of things were announced on the Azure blog (blog url) including some key ones around IaaS, Virtual Machines, Web Sites, and the Application Galleries.

HTML and AJAX Based Interface

The new portal runs on HTML and JavaScript, which means it can render on any browser that supports the core HTML functionality. This is great if you need to access it from a mobile device or tablet that doesn’t support plugins like Silverlight. The next thing you notice is that you get an at-a-glance view of all your running services, storage and networks.

image

Easily Create New Services

Adding a new service is as easy as clicking “NEW” on the bottom left corner of the screen and then making a selection of what you want to create. In addition to Cloud Services (formerly called Hosted Services) and storage, you can also create Virtual Machines, Web Sites, and Networks. These generally include a quick creation option which provisions the service with minimal configuraiton, but both Web Sit4es and Virtual machines include a “From Gallery” option which allows you to select a starting point to build from. 

image

This includes content management applications like Umbraco, DotNetNuke, Joomla, Das Blog, mojoPortal, and WordPress, or a Virtual Machines that already have SQL 2012 Eval, Windows Server 8 Beta, SUSE Linux, or Ubuntu installed and ready for your deployments. You can also save your own machines as starting points or upload your own VHD.

Yes, I did just say Linux. Running on Azure. In the Microsoft Cloud. Notice that the list of available images includes these as well as images I created!

image

The new dialogs walk you thru all the steps collecting the needed information in an easy to follow logical order to get the selected services up and running. Quick and easy, but where can you see the status and updates on these configuration tasks? That’s where the notification area at the bottom of the screen comes to bat. It provides a comprehensive spot for seeing summary and optionally more detailed information about your changes as they happen.

image 

Monitoring and Diagnostics

Beyond the provisioning of new services and configuration tasks you also can get great monitoring information about resources used by your cloud instances. By selecting a provisioned instance, clicking the name takes you to a details page where you can get deployment and configuration settings including database connection strings and more. You can quickly see how much usage you’ve used out of the available allocation that is part of the subscription.

image

You can easily get started today, just go out to http://windowsazure.com and try out the 90 Free Trial, or if you have an MSDN Subscription you can get compute time, storage and a lot more as part of your subscription benefits.

Enjoy!

-mike

Digg This

CloudTip #15-MEET Windows Azure

@MikeBenkovich 05/20/2012

imageThe Cloud comes in many flavors, types and shapes and the terminology can be daunting. You’ve got Public vs. Private. vs. Home grown. You’ve got compute, storage and database not to mention identity, caching, service bus and many more. Then there are the several players including Microsoft, Amazon, Rackspace, Force, and too many others to list them all.

That’s a lot to learn, but if you’re curious to see what’s been happening with the Microsoft Cloud and get a feel for the direction things are heading then you want to check out the recently announced Microsoft event “Meet Windows Azure” live in San Francisco on June 7, where the people who are in the drivers seat will take time to share their space.

While the details are sparse so far you can get more information on http://MeetWindowsAzure.com , as well as follow the happenings on twitter. It looks like an interesting event you won’t want to miss. With people like Scott Guthrie it’s sure to be full of great examples of what and how you can get started with Windows Azure and learn more about what you need to know to get started today.

Check it out today!

-mike


CloudTip #14-How do I get SQL Profiler info from SQL Azure?

@MikeBenkovich 05/18/2012

Your application is running slow. You need to find out what’s going on. If you’ve used SQL Profiler on a local database you might be familiar with how you can capture a trace of database activity and use it to figure out where your resources are going. The visibility makes it MUCH easier to tune a database than sorting thru a bunch of code. The question is, what do you do when you’re moving an app to the cloud?

If you’ve wondered how you can get Profile information from SQL Azure, the new online management portal for SQL Azure has been updated with design, deployment, administration and tuning features built in. The Overview screen provides quick links to the different areas of the portal, as well as easy links to help information from msdn online. You can get to the portal either by going to the Windows Azure management portal on http://windows.azure.com and after signing in going to the database section and clicking Manage, or simply browsing to your database name – https://<myserver>.database.windows.net where you substitute your database server’s name for <myserver>.

image

When I log in I can see my databases and get information about size, usage as well as the ability dive into specific usage. From there I can go into designing the schema, functions and code around my database. If I swap over to the admin page though, I have visibility into not just database size and usage, but also a link to query performance. Clicking this takes me to where I can see profile data from queries.

image

I can sort and see which calls to the database are most frequent as well as most expensive in terms of resource usage. Further I can select one and dive even deeper to see the execution plan and statistics around the calls. This information is key to making decisions on indexes and design of a well performing database.

image

In the query plan I can look for table scans or other expensive operations and if it make sense determine whether additional indexes would be useful.

image

Nice!

Digg This

CloudTip #13-What do you need to know to get started?

@MikeBenkovich 05/17/2012

imageThere are many ways to learn a new technology. Some of us prefer to read books, others like videos or screencasts, still others will choose to go to a training style event. In any case you need to have a reason to want to learn, whether it's a new project, something to put on the resume or just the challenge because it sounds cool. For me I learn best when I've got a real project that will stretch my knowledge to apply it in a new way. It also helps to have a deadline.

I've been working for a while now for Microsoft in a role that allows me to help people explore what's new and possible with the new releases of technology coming out at a rapid pace from client and web technologies like ASP.NET and Phone to user interface techniques like Silverlight and Ajax, to server and cloud platforms like SQL Server and Azure. The job has forced me to be abreast of how the technologies work, what you can do with them, and understanding how to explain the reasons for why and how they might fit into a project.


Try Azure for 90 Days Free!

In this post I'd like to provide a quick tour of where you can find content and events on Cloud Computing that should help you get started and find answers along the way.

Part 1 - Get Started with Cloud Computing and Windows Azure.
You've heard the buzz, your boss might even have talked about it. In this first webcast of the Soup to Nuts series we'll get started with Windows Azure and Cloud Computing. In it we will explore what Azure is and isn't and get started by building our first Cloud application. Fasten your seatbelts, we're ready to get started with Cloud Computing and Windows Azure.
Video; WMVMP4 Audio; WMA Slides: PPTX

Part 2 - Windows Azure Compute Services
The Cloud provides us with a number of services including storage, compute, networking and more. In this second session we take a look at how roles define what a service is. Beyond the different flavors of roles we show the RoleEntryPoint interface, and how we can plug code in the startup operations to make it easy to scale up instances. We will show how the Service Definition defines the role and provides hooks for customizing it to run the way we need it to.
Video; WMVMP4 Audio; WMA Slides: PPTX

Part 3 - Windows Azure Storage Options
The Cloud provides a scalable environment for compute but it needs somewhere common to store data. In this webcast we look at Windows Azure Storage and explore how to use the various types available to us including Blobs, Tables and Queues. We look at how it is durable, highly available and secured so that we can build applications that are able to leverage its strengths.
Video; WMVMP4 Audio; WMA Slides: PPTX

Part 4 - Intro to SQL Azure
While Windows Azure Storage provides basic storage often we need to work with Relational Data. In this weeks webcast we dive into SQL Azure and see how it is similar and different from on-premise SQL Server. From connecting from rich client as well as web apps to the management tools available for creating schema and moving data between instances in the cloud and on site we show you how it's done.
Video; WMVMP4 Audio; WMA Slides: PPTX

Part 5 - Access Control Services and Cloud Identity
Who are you? How do we know? Can you prove it? Identity in the cloud presents us with the same and different challenges from identity in person. Access Control Services is a modern identity selector service that makes it easy to work with existing islands of identity such as Facebook, Yahoo and Google. It is based on standards and works with claims to provide your application with the information it needs to make informed authorization decisions. Join this webcast to see ACS in action and learn how to put it to work in your application today.
Slides: PPTX

Part 6 - Diagnostics & Troubleshootingx
So you've built your Cloud application and now something goes wrong. What now? This weeks webcast is focused on looking at the options available for gaining insight to be able to find and solve problems. From working with Intellitrace to capture a run history to profiling options to configuring the diagnostics agent we will show you how to diagnose and troubleshoot your application.

Part 7 - Get Started with Windows Azure Caching Services with Brian Hitney (http://bit.ly/btlod-77)
How can you get the most performance and scalability from platform as a service? In this webcast, we take a look at caching and how you can integrate it in your application. Caching provides a distributed, in-memory application cache service for Windows Azure that provides performance by reducing the work needed to return a requested page.

Part 8 - Get Started with SQL Azure Reporting Services with Mike Benkovich (http://bit.ly/btlod-78)
Microsoft SQL Azure Reporting lets you easily build reporting capabilities into your Windows Azure application. The reports can be accessed easily from the Windows Azure portal, through a web browser, or directly from applications. With the cloud at your service, there's no need to manage or maintain your own reporting infrastructure. Join us as we dive into SQL Azure Reporting and the tools that are available to design connected reports that operate against disparate data sources. We look at what's provided from Windows Azure to support reporting and the available deployment options. We also see how to use this technology to build scalable reporting applications

Part 9 - Get Started working with Service Bus with Jim O'Neil (http://bit.ly/btlod-79)
No man is an island, and no cloud application stands alone! Now that you've conquered the core services of web roles, worker roles, storage, and Microsoft SQL Azure, it's time to learn how to bridge applications within the cloud and between the cloud and on premises. This is where the Service Bus comes in-providing connectivity for Windows Communication Foundation and other endpoints even behind firewalls. With both relay and brokered messaging capabilities, you can provide application-to-application communication as well as durable, asynchronous publication/subscription semantics. Come to this webcast ready to participate from your own computer to see how this technology all comes together in real time.

Enjoy!

-mike

Digg This

Easy Money

@MikeBenkovich 05/10/2012
Want to win some easy money? We have a sweepstakes, where we are giving away seven $50 gift certificate each week until June 14th. Just enter once, and you are in each drawing until the end.

To enter, you must do all of the following:

If you are selected as a winner we will need your Azure subscription ID to verify your Windows Azure subscription. Limit one (1) entry per Windows Azure subscription overall.

The official rules are posted on here.

Digg This

Cloud Tip #12-Get Started with SQL Azure

@MikeBenkovich 04/27/2012

Business Software is in the business of data management. Creating, updating, deleting and using information in new ways as well as simplifying how it is collected and reported is key to what we do as technology professionals. With the advent of Cloud Computing being able to take advantage of relational data directly in the cloud using the same skills we’ve been using with solutions built on premise means we’ll spend less time on the good old learning curve. One great example where this is the case is SQL Azure, the relational database service from Microsoft.

If you’ve been working with SQL Server for any length of time you’ll know that at its base it is a relational database engine that talks on port 1433 and speaks a language called Tabular Data Stream (or TDS). Common tools for working with SQL Server on premise includes SQL Server Management Studio (SSMS), BCP, Integration Services, Visual Studio, and many more too numerous to name. What is interesting about SQL Azure is that it uses the same protocols and ports as SQL Server you run on premise, so all the same tools continue to work. In this post I’d like to show how to get started working with SQL Azure quickly, provisioning a server, creating a database and some schema, and then migrating data to it.


Get the Azure 90 day Free Trial

Provisioning a Server

First thing we need is a service running in a datacenter to host our databases from. This is a logical service that represents many physical machines. We provision a server by going to the Windows Azure management portal (http://windows.azure.com) and selecting the Database section. From there we select our subscription and then click the Create button in the ribbon.

image

This will provision a SQL Azure service in a specified data center. The management tool lets you select the data center and set administrative credentials. These credentials are whatever you want, but with a couple restrictions. For example it disallows certain usernames for the admin  account including SA, Root, Admin, Guest, etc. Next it requires a strong password which includes 3 of the 4 types of characters on the keyboard (Upper Case, Lower Case, Numbers, and/or Symbols). The last step is to set up some firewall rules which specify who can see the server. By default there are no rules included, you even need to check the box to allow Windows Azure Services to see the server. You should also add a rule for your development machine, but be aware that it’s looking at the external facing IP address. Fortunately when you click the Add button it includes your external facing IP address.

image  image  image

Once this is done you’ll see you have a new database service created. The server name is auto generated for you and is part of the *.database.windows.net domain. It includes a master database (which is used by the system, no charge to you), and you can add databases as needed. To create a database select your server and then click the “Create” button.

image

You’ll see a dialog that prompts you to decide the size of database and the name. You have options for Web and Business and sizes ranging from 1 GB to 150 GB.

 image

After creating the database the ribbon provides  buttons which include functionality such as management of the schema and performance data from your database, as well as tools to import and export the data and schema. You can also drop the database and/or the server from the ribbon.

image

In the right pane you’ll find properties about your database. The pieces of information that are most useful include the allocated size, actual size, management URL (which is simply the generated name + .database.windows.net), and a link button to see examples of the connection strings you’ll use in your application to connect to SQL Azure.

image

So that’s it. I’ll go into the web based management tool in another post, but the key is that it is very easy to get up and started working with SQL Azure. In less than 5 minutes you can provision a service and be up and running with your database in the cloud.

Enjoy!
-mike

Digg This

Cloud Tip #11-Activate your MSDN Benefits

@MikeBenkovich 04/18/2012

If you have an MSDN Subscription you get Azure benefits which you can use to develop in the cloud. In this post I’d like to share what’s involved in activating these.

image

As you can see there are some pretty hefty benefits available that you can start using immediately. To get going log into the MSDN Subscription site http://msdn.microsoft.com/subscriptions and log in to see your account.

image

After you select the MSDN Subscription you’re working with, click the link to Activate Windows Azure. It will navigate to the Azure account management page and begin the process of activation. Depending on the level of subscription you have you’ll see details on the amount of resources that are included with your benefits. All that will be required to activate them is a credit card.

image

Next enter your credit card info, and click to continue…Note that although the credit card is required for activation, a cap is applied to the account and your subscription will be suspended if your reach any of the usage limits for the duration of the billing cycle (month).

image  image  image

After validating the credit card your account is provisioned. To see information about your active subscriptions click on the Account link to see details. As the third screen shows my account has a $0 spending limit attached to it, so I will not be billed for the duration of my subscription unless I remove the cap. More on that in another post.

Happy Coding!

Digg This

Cloud Tip#10-Use the Windows Azure Toolkit for Windows 8 to add interaction to your Metro Applications

@MikeBenkovich 04/17/2012

Yesterday in Bangalore at the GIDS conferences I did a session on working with Windows 8 and Notification Services. In it we talked about the live tiles that make up the new start screen in Windows 8 and how as a developer you have new ways to interact with your users thru the use of Toast, Tile, Badge and Raw notifications. We explored the 2 pieces of the puzzle that as developers we need to build, and showed how to make it all work.

WAT8screenshot

The client app and the Cloud service make up the 2 parts of the equation, and the process is fairly simple. The client application developer registers their application with Windows Push Notification Service (WNS), then requests a channel to be notified on. It sends that channel to it’s Cloud partner who persists the channel and then uses that to send notifications thru WNS to the client. The result is a very rich interactive experience. There are many templates and formats for the notification to take, and as a developer all you need to do is select the one you want and send thru the appropriate values.

image

The tools and technologies you need include 2 versions of Visual Studio, including Visual Studio 2010 with the Windows Azure SDK 1.6 installed, and Dev11 to build the Metro style client application on Windows 8. This Starting from scratch there are NuGet packages you could use, but a MUCH easier path is to use the Windows Azure Toolkit for Windows 8 hosted on http://watwindows8.codeplex.com. Nick Harris has a great blog post that talks thru the contents of the kit and details for installing, but the basic premise is that on a 32 GB developer tablet (small disk) I was able to install all the parts I needed to be able to make it work and still had 10 GB left over after installing everything.

Enjoy!

Digg This

Cloud Tip #9-Add Microsoft.IdentityModel to the GAC with a Startup Task

@MikeBenkovich 04/07/2012

Access Control Services is one of the many services that are part of the Windows Azure Platform which handles an authentication conversation for you, allowing you an easy way to integrate cloud identity from providers like Yahoo, Google, Facebook and Live ID with your application. You need an active Azure Subscription (click here to try the 90 day Free Trial), add an ACS service namespace, then add a Secure Token Service (STS) reference to your  application (you’ll need the Windows Identity SDK and tools for Visual Studio to add the Federation Utility that does that last part – download here).

imageIf you’ve seen an error that says ‘Unable to find assembly Microsoft.IdentityModel’ and wondered what’s the deal? In the documentation for working with a Secure Token Service (STS) you might have seen that this assembly is not part of the default deployment of your Windows Azure package, and that you’ll need to add the reference to your project and set the deployment behavior to deploy a local copy with the application…all good, right?

So you follow the instructions and still get the error. One reason for this is that you might be seeing an error caused by calling methods from the serviceRuntime which changes the appdomain of your webrole. In that case you should consider adding a Startup Task to load the WIF assembly in the Global Assembly Cache.

The basic logic is that in the startup of the web role you’ll need to inject a startup task to run the gacutil executable to do the installation. I created a startup folder in my web project to contain the scripts and files necessary, including a copy of gacutil.exe, a configuration file for it, and a batch file “IdentityGac.cmd” to contain the script commands needed.

I copied the gactuil.exe and config files from my C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64 directory, and put them in the Startup folder. Next I created a cmd file (in notepad) with the commands to install the assembly into the GAC. I found a post that discusses how to create a script to do the installation on http://blogs.infosupport.com/adding-assemblies-to-the-gac-in-windows-azure/ where it installs the Windows Identity files and then sets the windows update service to on demand, installs the SDK, then runs gacutil.

    @echo off
    sc config wuauserv start= demand
    wusa.exe "%~dp0Windows6.1-KB974405-x64.msu" /quiet /norestart
    sc config wuauserv start= disabled
    e:\approot\bin\startup\gacutil /if e:\Approot\bin\Microsoft.IdentityModel.dll

I add these files to the Startup folder, and then open the properties for the 3 files and set the build action to none and “Copy to Output Directory” to Copy Always. This ensures that these files will be present in the deployed instance for my startup task. Next we edit the startup tasks in the Service Definition file, adding a section for <Startup>, and a <Task… to run our script file.

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="MplsKickSite.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
  <WebRole name="MplsKickSite" vmsize="ExtraSmall">
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="Endpoint1" endpointName="Endpoint1" />
        </Bindings>
      </Site>
    </Sites>
    <Endpoints>
      <InputEndpoint name="Endpoint1" protocol="http" port="80" />
    </Endpoints>
    <Startup>
      <Task commandLine="Startup\IdentityGac.cmd" executionContext="elevated" taskType="simple">
      </Task>
    </Startup>
    <Imports>
      <Import moduleName="Diagnostics" />
      <Import moduleName="RemoteAccess" />
      <Import moduleName="RemoteForwarder" />
    </Imports>
  </WebRole>
</ServiceDefinition>

In Steve Marx’s post on Startup Task Tips & Tricks he suggests that when debugging a new startup task to set the taskType to background instead of simple so that it won’t prevent Remote Desktop from getting configured. If you’re interested to download the Startup folder I used I’ve uploaded a zip archive file with the files here.

Happy Coding!

Digg This

Cloud Tip #8-Using ACS without SSL

@MikeBenkovich 04/06/2012

Today I showed a work around for when you are showing ACS on a site that is running without setting up the SSL piece.


<
system.web>
  <!--Hack to get past request token on non-SSL site—>
  <httpRuntime requestValidationMode="2.0" />
  <pages validateRequest="false" controlRenderingCompatibilityVersion="4.0" 
        
clientIDMode="AutoID"></pages>

          ...

imageNote that shutting off validation of requests is not recommended, as it opens exploits against your site. For a better way of approaching this, Sandrino Di Mattia does a great job of explaining the right way of how to deploy and use the access control service in an Azure deployed solution.

http://fabriccontroller.net/blog/a-few-tips-to-get-up-and-running-with-theazure-appfabric-access-control-service

Make sure you add a reference to Microsoft.IdentityModel v3.5.0.0 and then set the properties of the assembly to copy local with the deploy.

On another track we looked at how to explore the claims that are included as part of the returned identity. In the Azure event I also showed a page that shows the contents of the user identity and display information about the claims contained in the token returned from ACS. I created a page in a secure location, then added a simple data grid to the page (called GridView1 and then in the page load I pull the identity information from the authenticated user data. The code for the PageLoad is below:

  

        protected void Page_Load(object sender, EventArgs e)
        {

           
try
            {
               
// Cast the Thread.CurrentPrincipal
                IClaimsPrincipal icp = Thread.CurrentPrincipal as IClaimsPrincipal
;

               
// Access IClaimsIdentity which contains claims
                IClaimsIdentity claimsIdentity = (IClaimsIdentity
)icp.Identity;

               
// icp.Identity.Name;
                // txtAuthName.Text = claimsIdentity.Name;
                
                txtAuthType.Text = claimsIdentity.AuthenticationType;
                txtIsAuthenticated.Text = claimsIdentity.IsAuthenticated.ToString();


               
var myClaims = from c in
claimsIdentity.Claims
                              
select new
{ c.ClaimType, c.Value };


                GridView1.DataSource = myClaims;
                GridView1.DataBind();


               
// Enable secret content for administrators
                if (Thread.CurrentPrincipal.IsInRole("Administrator"
))
                {
                   
this.secretContent.Visible = true
;
                }
            }
           
catch (Exception ex)
            {
                txtAuthType.Text = ex.Message;
            }
        }

Enjoy!

Digg This

Cloud Tip #7-Configuring your firewall at work for cloud development

@MikeBenkovich 04/05/2012

I had a question after a Windows Azure Camp about what ports need to be opened and enabled at my work environment to enable working with Windows Azure. While the services work with REST there are a couple services that will benefit from adjusting the firewall to allow traffic between on-premise and the cloud. I found settings for Service Bus and SQL Server, and the settings are below…

Service Bus

-Minimal: Enable outbound http on port 80 and 443, authenticated against proxy server if any

-Optimal: Allow outbound on port 9350 to 9353, can limit to well known IP range

- 9350 unsecured TCP one-way client

- 9351 Secured TCB one-way (all listeners, secured clients)

- 9352 Secured TCP Rendezvous (all except one way)

- 9353 Direct Connect Probing Protocol (TCB listeners with direct connect)

SQL on-Premise via Windows Azure Connect

-In SSMS - Enable Remote Connections on SQL Server properties window

-In SQL Server Configuration Manager

- Disable or stop SQL Server Browser

- Enable TCP/IP in the SQL Server Network Configuration | Protocols for server

- Edit TCP/IP protocol properties and set TCP Dynamic Ports to Blank, and then specify TCP Port to 1433

- Restart SQL Service

-In Windows Firewall add the following rules

- Inbound Port 1433 (TCP) Allow the connection

- Apply to all profiles (Domain, Private and Public)

- Name the rule something significant

Enjoy!

 

Digg This

Cloud Tip #6-Encrypting the web.config with Visual Basic

@MikeBenkovich 04/03/2012

One of the great things about Windows Azure is that it is a platform that is for the most part agnostic about what frameworks and languages you want to use. While I tend to do most of my demos in C# there is no reason we couldn’t use VB, PHP, Node.js, Java or any other language. In fact the developer story for the Microsoft Cloud is that if it runs on Windows it can run in Windows Azure. All you need is to configure the machine appropriately (more on that in another post). You can learn more about the tools by checking out the Tools section of the Windows Azure site.

For this CloudTip I got a request for how to do the encryption of the web.config but this time in VB. The logic is about the same, although I found that in VB I had to add a line to the configuration to save the new settings. The code for this in vb.net (adding to the global.asax file in the "Session_Start" subroutine…

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)

    ' Code that runs when a new session is started 

    EncryptSection("appSettings")

End Sub

Private Sub EncryptSection(ByVal sSection As String)

    Dim config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Context.Request.ApplicationPath)

    Dim configSection As ConfigurationSection = config.GetSection(sSection)

    If configSection.SectionInformation.IsProtected = False Then

        configSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider")

        config.Save()

    End If

End Sub

If you have questions about Cloud that would make a great Cloud Tip topic send them to me at my email or comment on the post.

Thanks!


Cloud Tip #5-Secure your settings in Web.config with Encryption

@MikeBenkovich 04/02/2012

In Windows Azure and especially with SQL Azure we need to store passwords to access things. I wanted to show how you can encrypt the web.config file by adding code to the global.asax file. The cool part of this is that using this technique you can secure application specific settings like connection strings and other data in the unlikely event that someone is able to get a copy of the configuration file (like by copying it to a thumb drive from the host machine or something similar).

The basic logic is to create a variable that points to a configuration section, then checking that the section is protected (i.e. encrypted). If it isn't, then call the ProtectSection method to encrypt the contents. The server uses the local DPAPI (Data Protection API) to encrypt the configuration section with a machine specific key, so only that machine can decrypt the contents. The code to add to the global.asax.cs file in the Application Start event for this is:

protected void Session_Start(object sender, EventArgs e) 
{ 
    EncryptSection("appSettings"); 
} 
     
private void EncryptSection(string sSection)
{
    Configuration config = System.Web.Configuration
                             .WebConfigurationManager
                             .OpenWebConfiguration
                             (Context.Request.ApplicationPath);

    ConfigurationSection configSection =
        config.GetSection(sSection);

    if (!configSection.SectionInformation.IsProtected)
    {
        configSection.SectionInformation.ProtectSection
        ("DataProtectionConfigurationProvider");
        config.Save();
    }
}

Happy Coding!

Digg This

Cloud Tip #4-How to migrate an existing ASP.NET App to the Cloud

@MikeBenkovich 04/01/2012

Suppose you have an existing application that you want to migrate to the cloud. There are many things to look at, from the data to the architecture to considering how you plan to scale beyond one instance. For simple web sites which don’t use a lot of data or stateful information the migration to the cloud can be pretty easy with the installation of the Visual Studio Tools for Windows Azure.

imageThe current release of the tools (as of March 2012) is v1.6 which adds a command to the context menu when you right click on a web project. The SDK is installed using the Web Platform Installer (aka WebPI) which checks for previous versions of the tools and any other prerequisites and the consolidates the install into a single step.

imageAfter installing the tools when you open a Web Project, whether ASP.NET Web Forms, MVC, or similar, right clicking the project file gives you the command to add an Azure Deployment Project. You could achieve something similar by simply adding a Cloud Project to your solution and then right clicking on the “Roles” folder and adding the existing site to the project.

This adds a Cloud project to the solution and then adds the current Web project as a standard Web Role in the deployment. The key assets added include a Service Definition file and a couple Service Configuration files (one for running locally and one for running in the cloud).

The Service Definition file includes markup which describes how the Cloud Service will be deployed, including the public ports that are enrolled in the load balancer, any startup tasks and plugins that you want to run, as well as any other custom configuration that should be part of the deployment.

For example the Service Definition we created for the Kick Start event in Minneapolis looked like this:

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="MplsKickSite.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
  <WebRole name="MplsKickSite" vmsize="Small">
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="Endpoint1" endpointName="Endpoint1" />
        </Bindings>
      </Site>
    </Sites>
    <Endpoints>
      <InputEndpoint name="Endpoint1" protocol="http" port="80" />
    </Endpoints>
    <Imports>
      <Import moduleName="Diagnostics" />
    </Imports>
  </WebRole>
</ServiceDefinition>

In this code we’ve got a single web role being deployed that will run on port 80. It is running a small instance (1 dedicated core), and will have remote desktop enabled. The Service Configuration contains additional settings including the OS Family for the instance (1 = Windows Server 2008 SP2 and 2 = Server 2008 R2) and number of instances to run (in this case 3).

<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="MplsKickSite.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" 
osFamily="2" osVersion="*"> <Role name="MplsKickSite"> <Instances count="3" /> <ConfigurationSettings> <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" /> <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="true" /> <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="... <Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="...
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="... <Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="true" /> <Setting name="QueueName" value="createthumbnail" /> <Setting name="myStorageAcct" value="UseDevelopmentStorage=true" /> </ConfigurationSettings> <Certificates> <Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="... </Certificates> </Role> </ServiceConfiguration>

Pressing F5 will run the Cloud Service in the local emulator (assuming we’re running Visual Studio as Administrator so it can communication cross process to the running services…an error message tells you if you’re not). The nice thing about this approach is it supports attaching to the local debugger and using the rich set of features such as breakpoints, local and watch variables, and all the rest of the goodness we’ve come to expect in Visual Studio debugging.

image

Once we’re satisfied that the application works and we are ready to go to the Cloud, you can right click on the Azure Deployment project and either click “Package” to create a deployment package which you can manually upload the the Windows Azure Management portal, or you can select Publish to automate it directly from Visual Studio. This runs a wizard with 3 basic steps to collect the necessary information and complete the deployment. You select the subscription you want to use, name the hosted service, optionally enable remote desktop and web deploy, and then click complete.

image   image  image

Note that if you enable Web Deploy, because this is only supported for a single instance development environment where you require the ability to publish changes to a web site quickly, the publishing process will change your configured number of instances to 1 despite having set it to 3 in the configuration files. That’s because if you have more than 1 instance deployed the load balancer will distribute the incoming web requests round robin, and if you change one of the instances with a web deploy you’ll have an inconsistent state. You can always change the number of instances from the management portal, but you should be aware of what you’re doing.

imageimage

What happens next is the deployment process takes place. This includes validating that the hosted service is provisioned for you, uploading certificates if needed, then uploading your deployment package and configuration files to Windows Azure storage, and then deploying and starting your instances. It will also add the service deployment to the Server Explorer window (CTRL + ALT + S). From there you can see the status of your service instances, download the profile or intellitrace files if you’ve enabled that option (under advanced features during the publish).

For more information on how to do this, or if you’d like to see a webcast on how this is done, check out the first webcast in the Cloud Computing Soup to Nuts series (http://bit.ly/s2nCloud).

Enjoy!

Digg This

Cloud Tip #3–Find good examples

@MikeBenkovich 03/31/2012

imageYesterday in Minneapolis we delivered the first Windows Azure Kick Start event of the series we’re running this spring to help developers learn and understand how to use the new tools and techniques for building cloud based applications. As part of that event we wrote a lot of code as a demonstration of how this stuff comes together and I’ve uploaded it to www.benkotips.com in case you’re interested in the download. The solution includes several projects including:

  • MplsKickSite - An existing ASP.NET web site that we migrated to Windows Azure, implementing the RoleEntryPoint interface and adding references to the Microsoft.WindowsAzure.StorageClient for working with storage, and Microsoft.WindowsAzure.ServiceRuntime to give us instance information. We also added cloud identity to the site using Access Control Services to secure a data entry page with data hosted in a SQL Azure database
  • WPFUpload which is a Windows application which includes logic to support drag and drop to upload files into Windows Azure Blob Storage, and if they are images to add work to a queue to create thumbnail images
  • UploadDataLib which is a class library that implements Windows Azure Table Storage logic for working with the images uploaded by WPFUpload and the ThumbMaker worker role projects.
  • ThumbMaker which is a worker role class that demonstrated working with Tables and Queues and the System.Drawing library to create thumbnail images and brand them with a custom logo message
  • PhoneApp1 which demonstrates how to use a Windows Phone Silverlight user control to handle the login conversation with ACS
  • NugetPhone which is a second example of ACS in use with devices, except that instead of spending 10 minutes to write the code like we did with PhoneApp1 we use the Nuget package manager to include a package (Install-Package Phone.Identity.AccessControl.BasePage) to perform the authentication for us and make the 4 code changes to implement the logic…2 minutes to demo

The decks and recordings of similar sessions are available on the Soup to Nuts Cloud Computing page of my site (http://bit.ly/s2nCloud). You can download the solution and project files and run every thing with the Compute and Storage Emulator, but you’ll need an active subscription to deploy to the cloud. If you don’t have Azure benefits you can activate from an MSDN Subscription you can always give the 90 day Free Trial a try.

Enjoy!

Digg This

Cloud Tip #2–Finding Cloud Content that works for You

@MikeBenkovich 03/29/2012

imageThere are many ways to learn a new technology. Some of us prefer to read books, others like videos or screencasts, still others will choose to go to a training style event. In any case you need to have a reason to want to learn, whether it’s a new project, something to put on the resume or just the challenge because it sounds cool. For me I learn best when I’ve got a real project that will stretch my knowledge to apply it in a new way. It also helps to have a deadline.

I’ve been working for the last several years now for Microsoft in a role that allows me to help people explore what’s new and possible with the new releases of technology coming out at a rapid pace from client and web technologies like ASP.NET and Phone to user interface techniques like Silverlight and Ajax, to server and cloud platforms like SQL Server and Azure. The job has forced me to be abreast of how the technologies work, what you can do with them, and understanding how to explain the reasons for why and how they might fit into a project.

In this post I’d like to provide a quick tour of where you can find content and events on Cloud Computing that should help you get started and find answers along the way.

First on my list are the webcasts we’ve created that are 1 hour long sessions on the various aspects of a given topic. For Cloud Computing and Windows Azure I’ve got a list of several on my web site (www.benkotips.com) including a 27 part companion series we called “Windows Azure Boot Camp”. The first 10 webcasts in this series cover what you would see at a boot camp event (www.windowsazurebootcamp.com).  This spring we started a new series called “Cloud Computing Soup to Nuts” which is a developer focused get started with Windows Azure and the related services. We’ve recorded 6 webcasts as part of that series and will be adding more as we go forward. We just added 3 more for April including:

4/3 : Part 7 - Get Started with Windows Azure Caching Services with Brian Hitney (http://bit.ly/btlod-77)
How can you get the most performance and scalability from platform as a service? In this webcast, we take a look at caching and how you can integrate it in your application. Caching provides a distributed, in-memory application cache service for Windows Azure that provides performance by reducing the work needed to return a requested page.

4/10 : Part 8 - Get Started with SQL Azure Reporting Services with Mike Benkovich (http://bit.ly/btlod-78)
Microsoft SQL Azure Reporting lets you easily build reporting capabilities into your Windows Azure application. The reports can be accessed easily from the Windows Azure portal, through a web browser, or directly from applications. With the cloud at your service, there's no need to manage or maintain your own reporting infrastructure.  Join us as we dive into SQL Azure Reporting and the tools that are available to design connected reports that operate against disparate data sources. We look at what's provided from Windows Azure to support reporting and the available deployment options. We also see how to use this technology to build scalable reporting applications

4/17 : Part 9 – Get Started working with Service Bus with Jim O’Neil (http://bit.ly/btlod-79)
No man is an island, and no cloud application stands alone! Now that you've conquered the core services of web roles, worker roles, storage, and Microsoft SQL Azure, it's time to learn how to bridge applications within the cloud and between the cloud and on premises. This is where the Service Bus comes in—providing connectivity for Windows Communication Foundation and other endpoints even behind firewalls. With both relay and brokered messaging capabilities, you can provide application-to-application communication as well as durable, asynchronous publication/subscription semantics. Come to this webcast ready to participate from your own computer to see how this technology all comes together in real time.

If you’re looking for a conversational 30 minute show that covers Cloud topics I suggest checking out Cloud Cover on Channel9. This show features Azure experts including Ryan Dunn, Steve Marx, Wade Wegner, David Aiken and others who work closely with the product teams at Microsoft to learn how to use the latest releases.

Live events are a moving target depending on when you read this post, but we try to keep a list of upcoming Microsoft Events for developers on http://msdnevents.com. As we schedule them we add the events to this hub and you can find them by date and by location with a map of upcoming events. Another place to check is the demo page I’ve created on BenkoTips which shows not only upcoming events (aggregated from Community Megaphone, if you add it there it should show up on the map) but also User Group locations and links to their sites. That’s on http://benkotips.com/ug, then use the pan and zoom to focus the map on your city. Pins get added with the links. If your User Group data is out of date, send me an email & we’ll get it fixed.

We’ve got a series scheduled to run in thru May 2012 for Cloud Computing called Kick Start, which are a 1 day focused event that takes you thru the content from Soup to Nuts. The current schedule includes:

As to books I’d suggest checking out Sriram Krishnan’s book Programming Windows Azure: Programming the Microsoft Cloud, or Brian Prince’s book Azure in Action. If it’s SQL Azure that you’re after then Scott Klein has a great book called Pro SQL Azure (Expert’s Voice in .NET). I am also partial to the Patterns and Practices team’s book on Moving Applications to the Cloud on the Microsoft Azure Platform.

Finally you need an active Azure Subscription to get started. You can activate a 90 Free Trial by going to http://aka.ms/AzureTrialMB and get the tools at http://aka.ms/AzureMB.

Digg This

Cloud Tip #1–How to set a connection string in Web.config programmatically at runtime in Windows Azure

@MikeBenkovich 03/27/2012

The scenario is I’m migrating an application to the cloud. I’ve got a database connection defined in my web.config file which uses an on-premise SQL Server database and what I’d like to do is to move it to a Web Role on Windows Azure and use a SQL Azure database. The basic process is to add a Windows Azure Deployment Project to the solution that contains my web application. Next I move my database to SQL Azure (using the SQL Azure Migration Wizard), and then I change the connection string to point to the cloud database. Except that after I’ve deployed the project I may need to change where the database lives.


Try Azure for free - Activate a 90 day trial at http://aka.ms/AzureTrialMB today!

Since that information is stored in Web.config all I need to do is redeploy a new web.config file to the Web Role and we’re good to go. Unfortunately that probably means an upgrade to the application or a VIP swap, which isn’t all bad, but I know that I can make changes to the ServiceConfiguration file and propagate the changes to the running instances…no down time. But how do I get a change in the Service Configuration into the web.config?

I have posted before how you can encrypt information stored in the web.config file during a Session_Start event by adding code to the Global.asax file to examine a section and then call protect. If I can add some code to determine whether I’m running in Azure, and if I am to read the setting from the ServiceConfiguration file then we should be good.  Like the example of encrypting settings an approach that works well is to add code to the Session_Start event. For my example I’ve created a setting in the Windows Azure Role for dbConnectionString and set it to the value I’d like to use.

image

Next I make sure I add a reference to the Microsoft.WindowsAzure.ServiceRuntime namespace added to the web project so I can access information about the role. If I don’t have one already I add a global.asax file to my web project. This would be where I can add code for the events that fire periodically throughout the lifecycle of my app. I choose to use the Session_Start because if I’ve made changes to my ServiceDefinition file they will get applied the next time someone browses to my site. 

        public string dbConnectionString { get; set; }
 
        void Session_Start(object sender, EventArgs e)
        {
            // Are we running in Azure?
            if (RoleEnvironment.IsAvailable == true)
            {
 
                dbConnectionString = RoleEnvironment.GetConfigurationSettingValue("dbConnectionString");
 
                // Do we have a value for the alternate dbConnectionString in the ServiceConfiguraiton file?
                if (dbConnectionString != null)
                {
                    Configuration myConfig = WebConfigurationManager.OpenWebConfiguration("~");
                    ConnectionStringsSection mySection = myConfig.GetSection("connectionStrings") as ConnectionStringsSection;
                    if (mySection != null)
                    {
                        if (mySection.ConnectionStrings["myDBConnectionString"].ConnectionString != dbConnectionString)
                        {
                            mySection.ConnectionStrings["myDBConnectionString"].ConnectionString = dbConnectionString;
                            myConfig.Save(ConfigurationSaveMode.Modified, true);
                        }
                    }
                }
            }
        }

I check to see whether the value in the Service Configuration file is different than the value in my web.config, and if it is then make the change and save it. Initially when I tested the code I got a “the configuration is read only” error, but by adding the option for the Save method it works. Now I am able to update the database connection string from the Service Configuration File and have it propagate to my web.config of the running application.

Credit goes where credit is due, and Bing pointed me to a few posts on the subject, including StackOverflow and DotNetCurry.

Enjoy!

Digg This

Questions on Tuning SQL Queries

@MikeBenkovich 03/14/2012

Sometimes I get questions about how to get better performance from a database. In working with SQL Server over the years and now SQL Azure this is not an uncommon question. In SQL 2008 and beyond the tools include a Tuning Wizard, which is great, but it relies on capturing a realistic sample of the database activity which you can get with SQL Profiler. Just go to the tool and run it, saving the captured trace to a table in SQL so you can look at it later and do some analytics.

Here’s some thoughts and ideas, for what they’re worth. First thing I would look at is to take a profile sample of the application running, which captures the queries and the statistics around which tables are being used and can be fed into the tuning utility to suggest indexes and keys. The second thing I would look at is whether a permanent working table would work better than a Temp table. The advantage is you have index capabilities, but the downside is truncating it and loading it when you need it.

Do you have flexibility with the schema to look at ways to pre-populate the data you need for the report during normal runtime of your system? For example if you are doing validations and transformations could these be scheduled to run periodically or even as the data transactions occur so that the work doesn’t have to be done ad-hoc to generate the report?

As to the query syntax I’ve found the “NOT EXISTS” clause to give better performance than the IN or NOT IN because of the way the optimizer creates and executes the plan.

Finally if you have complex queries are you generating them on the fly or can you create functions/stored procedures where the execution plan is pre-compiled?

Digg This

Announcing Windows Azure Kick Start Events

@MikeBenkovich 03/12/2012

It’s spring and once again we’re back on the road to helping people explore the possible and see how to get started with Cloud Computing. Along with the webcast series I’ve been doing (http://benkotips.com/s2nCloud) we’ll be on the road to bring the content to your town. The schedule so far is listed below.

By the way if you have MSDN you have free cloud benefits! This video shows you how to get your risk free access to Azure to explore and learn the cloud or activate your MSDN Cloud benefits here. If you have questions send our Azure team members an email msnextde at microsoft.com.

See you on the road!

Digg This

Get Started with Cloud Computing and Windows Azure

@MikeBenkovich 03/04/2012

This is the first part of a series of blog posts I’m working on as part of the companion webcast series “Soup to Nuts Cloud Computing” in which we look at what it takes to get started with the tools and setup things you need to begin building Cloud applications. I will be focusing on Windows Azure as our target platform, but the topics we cover later on about architecting for scale, availability and performance apply across any Cloud Provider. I’m going to make the assumption that we’re on the same page as to what Cloud Computing is, which Wikipedia defines as

Cloud computing is the delivery of computing as a service rather than a product, whereby shared resources, software, and information are provided to computers and other devices as a utility (like the electricity grid) over a network (typically the Internet).[1]"”

I like the definition on SearchCloudComputing - http://searchcloudcomputing.techtarget.com which describes it this way:

“A cloud service has three distinct characteristics that differentiate it from traditional hosting. It is sold on demand, typically by the minute or the hour; it is elastic -- a user can have as much or as little of a service as they want at any given time; and the service is fully managed by the provider (the consumer needs nothing but a personal computer and Internet access).”

Assuming we agree on what it is, Windows Azure provides what is called “Platform as a Service” or PaaS to customers who want to build scalable, reliable and performant solutions to business information problems. Windows Azure is available on a Pay as you Go, as a Subscription Benefit or on a Trial basis. These are associated with a subscription which you create as the management point of contact for your services. The services available are fairly broad and include some core services such as Compute, Storage and Database, but also include several additional services that can be used in conjunction with or separate from the core services including Identity Management (Access Control Services), Caching, Service Bus, Reporting Services, Traffic Management, Content Delivery Network and more.

image

Using these services we can build a variety of applications and solutions for websites, compute intensive applications, web API’s, social games, device applications, media intensive solutions and much more. The thing we need to get started is an account or subscription which provides the interface to provision and manage these services. Fortunately there are many ways to get started.

The Subscription. If you have an MSDN Subscription or are part of the Microsoft Partner Network or have signed up for BizSpark you already have Azure Benefits that you just need to activate. Simply go to http://bit.ly/bqtAzMSDN to see how to activate. If none of these apply you can also try out the Free 90 Day Azure Trial (http://aka.ms/AzureTrialMB) which includes a cap which prevents accidental overage. When you activate your subscription it will walk you thru a series of steps which are needed to get things set up.

image  image  image

The first page shows us what we get with the subscription. Next it confirms your identity by sending a confirmation code to your cell phone. The process then asks for credit card information to validate your identity and then activates your account. The process is very fast and responsive (unlike the old 30 day Azure Pass we had used at the Boot Camps in 2011 which could take up to 24-48 hours to activate the trial.

image  image  image

The Tools. Next we get the tools. because there are lots of platform developers out there, you can get the tools that work for you, whether it’s Visual Studio, Eclipse, PowerShell or just command line tools. You’ll want to download the SDK and tools by going to http://aka.ms/AzureMB and clicking the appropriate link.

image

Our First App. Now that we have our tools, let’s look at what is needed to build and deploy an app. In the webcast we showed how to take an existing application and add the pieces needed to deploy it to the cloud. We start out in a Visual Studio Solution that has a simple ASP.NET web application. After we’ve installed the tools for Visual Studio when you right click on the web project file you will see a new option on the context menu to Add a Windows Azure Deployment Project to the solution.

image

This adds a new project to the solution and includes a service definition file and a couple configuration files. The Service Definition file (*.csdef) describes how our cloud application looks, including what type of roles are included (think front end web servers and back end processing servers), the endpoints that will be serviced by the load balancer and any internal endpoints we plan to use, as well as any startup configuration we need to run when our instances start up.

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="Soup2NutsSite.Azure1" 
                   xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
  <WebRole name="Soup2NutsSite" vmsize="Small">
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="Endpoint1" endpointName="Endpoint1" />
        </Bindings>
      </Site>
    </Sites>
    <Endpoints>
      <InputEndpoint name="Endpoint1" protocol="http" port="80" />
    </Endpoints>
    <Imports>
      <Import moduleName="Diagnostics" />
    </Imports>
  </WebRole>
</ServiceDefinition>

The Service Configuration files (*.cscfg) include things like connection strings, certificates and other pieces of information used by our running service instances that we may change after deployment.

Deploy. After adding the Windows Azure Deployment Project you can publish it out to the cloud by right clicking and selecting Publish. A wizard is presented which walks you thru the steps to build a package of files which includes zipped and encrypted copies of all the code and resources the application requires, as well as the configuration files to make your application work. You sign into your Windows Azure subscription setup a management certificate which authorizes Visual Studio to make deployments on your behalf. You can pick the subscription you want to use and then create a hosted service name and select a data center or region to run it in.

image  image  image

You can choose to enable Remote Desktop, where it will ask for an admin user name you’d like to use to manage the service, and optionally enable Web Deploy which adds the necessary plumbing to support WebDav deployment of your web code (a nice development feature where you can update the code running the website without doing a full deployment of the hosted service).  You end up with a Publish Summary that shows what and where you will deploy the site to.

image  image

Clicking Publish then goes thru the process of building your package, uploading it to the Windows Azure Management site, and starting your service. Visual Studio has a status window which shows where it’s at in the process, and you can see your deployment from the Windows Azure Management Portal and clicking on the “Hosted Services, Storage Accounts & CDN” button on the left panel of actions.

image

If you’re curious to see how much you’ve used of your subscription you can always go back to http://WindowsAzure.com and view your account details.

image

Conclusion. So that’s it. You can get started with Windows Azure and Cloud Computing very quickly, all you need is an active subscription, download the tools, and then do a quick deploy of a project.  For details on things like pricing check out the page on http://WindowsAzure.com.

Digg This

New Webcast Series–Cloud Computing Soup to Nuts

@MikeBenkovich 01/31/2012

Announcing the latest webcast series - Cloud Computing Soup to Nuts (http://bit.ly/s2nCloud). In this series we start at the beginning and take you thru the services and technologies that make up Windows Azure and SQL Azure. Running every week on Tuesdays join us to explore the possible with Cloud Computing. I’ll be updating this page as the registration links become available.

2/7 - Get Started with Cloud Computing and Windows Azure
You've heard the buzz, your boss might even have talked about it. In this first webcast of the Soup to Nuts series we'll get started with Windows Azure and Cloud Computing. In it we will explore what Azure is and isn't and get started by building our first Cloud application. Fasten your seatbelts, we're ready to get started with Cloud Computing and Windows Azure.

2/14 - Working with Windows Azure Roles
The Cloud provides us with a number of services including storage, compute, networking and more. In this second session we take a look at how roles define what a service is. Beyond the different flavors of roles we show the RoleEntryPoint interface, and how we can plug code in the startup operations to make it easy to scale up instances. We will show how the Service Definition defines the role and provides hooks for customizing it to run the way we need it to.

2/21 - Windows Azure Storage Options
The Cloud provides a scalable environment for compute but it needs somewhere common to store data. In this webcast we look at Windows Azure Storage and explore how to use the various types available to us including Blobs, Tables and Queues. We look at how it is durable, highly available and secured so that we can build applications that are able to leverage its strengths.

2/28 - Intro to SQL Azure
While Windows Azure Storage provides basic storage often we need to work with Relational Data. In this weeks webcast we dive into SQL Azure and see how it is similar and different from on-premise SQL Server. From connecting from rich client as well as web apps to the management tools available for creating schema and moving data between instances in the cloud and on site we show you how it’s done.

3/6 - Access Control Services and Cloud Identity
Who are you? How do we know? Can you prove it? Identity in the cloud presents us with the same and different challenges from identity in person. Access Control Services is a modern identity selector service that makes it easy to work with existing islands of identity such as Facebook, Yahoo and Google. It is based on standards and works with claims to provide your application with the information it needs to make informed authorization decisions. Join this webcast to see ACS in action and learn how to put it to work in your application today.

3/13 - Diagnostics & Troubleshooting
So you’ve built your Cloud application and now something goes wrong. What now? This weeks webcast is focused on looking at the options available for gaining insight to be able to find and solve problems. From working with Intellitrace to capture a run history to profiling options to configuring the diagnostics agent we will show you how to diagnose and troubleshoot your application.