Monday, August 4, 2014

Leaveraging BDD with Microsoft Azure and Visual Studio Online

 

BDD (Behavior Development Driven) and TDD are topics that are not new (my first post was in 2011).

Now that we have VSO, Visual Studio Online and Microsoft Azure, we can be even more Agile !

Without debating weather or not one should use BDD or TDD, this post focuses on how to do it the BDD way, and show that SpecFlow could handle easily French.

   

OBJECTIVE: From a “regular” specification (waterfall way) we are going to:

  1. Convert it into BDD,
  2. Write it down into Microsoft TFS / VSO, via Excel
  3. Implementer the Unit tests (helped by the BDD auto-generated code),
  4. The Dev is naturally going to ask questions to the PO (Product Owner) and one of the aim of BDD is to force them to talk ! and have a common language without having any misleading specification.
  5. Implements the code
  6. Performing Refactoring
  7. Prove the PO that the « Definition Of Done » based on the « Given-When-Then » of the BDD is compliant
  8. Il our case, I chose to implement with a 100%Code Coverage, since this is a sensitive and critical functionality
  9. With 100% of Code Coverage, even a slightest modification of the specs will be detected by the test harnesses and the Build machine.

Here is the “regular” Specification

Screen

Role

Profile

Visiteur

Manager

Utilisateur central

Admin

Ecran d 'accueil

Navigation

x

x

x

x

Activité prévisionnelle

Lecture

x

x

x

x

Saisie

x

x

x

Export csv

x

x

x

x

Performance

Lecture

x

x

x

x

Import & Export

Lecture

 

x

x

Lancement import

x

x

Lancement export

x

Utilisateurs

Lecture

x

x

x

Création / Modification

 

x

Paramètres

Lecture

x

x

Saisie alertes

x

x

Saisie paramètres généraux

x

Saisie paramètres généraux

x

 

STEP 1: Convert this table into BDD (In Order To – As a – I want ; and Given-When-Then)
as well as other Product Backlog Items directly into EXCEL (with a 2-way connection to Microsoft TFS / VSO)

If you are irritated with EXCEL, just use MS Project, Word or the TFS Web portal (below).

STEP 2: Let focus on one specific PBI
(displayed with IntelliSense within Visual Studio with the SpecFlow Add-on. Hence, one cannot write any specification since it is going to be compiled by MS Build or Visual Studio)

ETAPE 3: Let SpecFlow autogenerate the test harnesses from the BDD specification

According the the methodology « Red, Green, Refactor » (the you MUST ALWAYS follow in this order else you’ll end-up having tests that returns always True or you’ll forget to « refactor », …),

  1. I write the tests within the BDD auto-generated test hanesses. I run the tests that should fail (Red) {which is normal since I don’t have any code yet !}.
  2. I start implementing my 1rst code so that the tests becomes Green (with refactoring yet, so that if it’s wrong… you should fail fast)
  3. Once green, it’s time to Refactor which is great, since my code is so ugly that TFS refuses to archive my code.

 

BENEFIT N°1 : Refactoring

The refactoring forces me to have few iterations :

-          with ugly code: Maintainability Index = 20 and cyclomatic complexity = 105  (i.e. so complex that no one will want to maintain my code!! where one would say “Yes, but you know, this is a very complex use case, and I had to code 106 line of code! Which is obviously a bad excuse to produce bad code)

-          with less ugly code (Maintenability Index = 59 ; cyclomatic complexity = 63)

-          with maintainable code that fits into half-a-screen (Maintenability Index = 72 i.e. very maintainable; cyclomatic complexity = 28 i.e. not complex).
Rappel:  « Red, Green, Refactor » reminds me that my code can still be refactored to be even better… but at some point we have to deliver the code !

BENEFIT N°2 :

The code is centralized, which seams to be so obvious BUT the fact is that I can still find numerous projects with logic hardcoded into the GUI.

 

BENEFIT N°3 :

The code is protected by 100% of Code Coverage . i.e the slightest modification of the spec will be detected by VSO / TFS.

To cover the 100% of the needs, a hundred of tests are needed (since initially a hundred of line of code). They are wrapped up into only 2 BDD tests that represents 95+5 = 100 ms to execute automatically everytime a check-in is performed.
In the contrary, a “manual test” would have been boring to perform during hours.

image

The 100% of code coverage highlighted in blue ; even Throw Exceptions are tested to reach the 100%

BENEFIT N°4 : Everything is integrated to Visual Studio and Microsoft Team Foundation Server (TFS) or Visual Studio Online (VSO), with Continuous Deployment on Microsoft Azure

BENEFIT N°5: Have you ever read the specification ??

Now with BDD, the Spec becomes part of the « Definition Of Done » (DoD) and most importantly the specification are “bare bone” (i.e. you don’t write unnecessary text) and things that contradicts themselves are sometimes detected by the compiler.

That’s the end of the era where Product Owner would spend days and months to write specifications that are never read, or best are out of date and never synched with the code. Here the Word document is automatically generated by the Given-When-Then acceptance criteria.

      Friday, June 27, 2014

      Deprecated Azure services : SQL Federation and Azure Reporting Services

       

      If you are some of the few people who have tested / used Azure SQL Federation, you’ll be surprised, happy … or sad to know that Azure SQL Federation has been discontinued.

      Azure SQL Federation always has been a source of architectural debates since its creations about 3 years ago. Now this is official.


      We understand your concerns around the deprecation of the Federations in SQLDB. The change is necessary because of scaling limits in the current implementation of Federations and incompatibility with the newest features we are introducing in the cloud data platform. We will be investing over time in deeper guidance and capabilities to fill the gap – in the interim we recommend utilizing a “self-sharding” approach that many of our large scale customers (including those that host hundreds or thousands of DBs in Azure use) implement on our platform. Examples of sharding patterns for databases in Azure are covered in the Cloud Service Fundamentals samples and articles from the Azure CAT team -- http://social.technet.microsoft.com/wiki/contents/articles/17987.cloud-service-fundamentals.aspx .
      In any case, we would be interested in learning more about how you are using Federations today and what your highest priority requirements are for future capabilities, so I would welcome the opportunity for a phone discussion or separate email thread. Please reach out to me by email to stuarto at Microsoft dot com.
      Stuart Ozer
      Group Program Manager
      Azure SQL Database

      Stuart Ozer - Tuesday, June 3, 2014 1:01:39 AM

      Here is the official documentation: http://msdn.microsoft.com/library/azure/dn741330.aspx 

      image

      ===========

       

      Also, in case you missed it, Azure SQL Reporting also has been retired the 9th May, 2014: http://msdn.microsoft.com/library/azure/dn528853.aspx where IaaS VM with full SQL Server and SSRS is its replacement.

      In order to create such VM, I spent quite a lot of time configuring it particularly the security access despite detailed documentation. You will find a way of doing so a bit quicker based on a LARGE Powershell : http://msdn.microsoft.com/library/azure/dn449661.aspx

      image

      Wednesday, May 28, 2014

      Subtle difference between one VSO another one, both running on Microsoft Azure ;-)

       

      Let consider two Visual Studio Online (TFS running as a service on Microsoft Azure).

      Who would have thought that a difference would exist between 2 VSO accounts ?? Something unusual occurred to me when I wanted to add new users onto my new VSO account.

      You you see a difference between the left-hand side account and the right-hand side ? (apart from the URL!)

      imageimage

      On the left, VSO it requires a connection with Microsoft Azure Active Directory. On the right, it is not linked to AAD (look carefully on the bottom of the screen shot).

      What are the consequences ?

      First, when you want to link your VSO to a Microsoft Azure Account, it will detect the, say “thavo001.VisualStudio.com” belongs to the AAD “Objet Direct”.

      image

      where as the second case is not (“Not connected to a directory”).

      image

      Second, when you want to add a new user into your VSO, in the first case, you will have to add it also in the AAD, as reminded below:

      image

      Whereas, when “not connected to a directory”, adding a new user is instantaneous.

      This differences comes from a historical privilege that some of us had to be a VSO “Early Adopter” where AAD not not yet connected. Now a more secure way is to use your Microsoft Azure Account to instanciate a VSO account, where automatically an AAD would be associated.

      In your case, do you see other differences and side effects ?  ;-)

       

      TODAY, you do not have the choice, you MUST be in the Azure Directory; the new portal reminds you so:

      image 

      as documented here: http://www.visualstudio.com/en-us/dn655138

       

      Note: Renaming VSO accounts could be risky since other users will loose the current URL. Sometimes Microsoft reminds you that with interesting CSS colors/icons! (I love HTML 5 so much easier to trouble shoot that Silverlight … well, I wish ! )

      image 

      and the full list of icons are found here (I had to reduce):

      image

      Wednesday, May 21, 2014

      Summary of the 1rst Global Azure Bootcamp Lyon in France 2014

       

      This is a report of the first Global Azure Bootcamp in Lyon, that welcomed over 120 people.
      It is an international event involving more than 138 cities in the world in 56 countries. The association MUG -Lyon was chosen to organize the Lyon edition! And I was the lucky person who has organized all this with many partnership.

      Over 16 experts were speakers, ranging from:


      • Many MVP from France honored the event by becoming speakers : they came Grenoble, Marseille, Lyon. Even a RD, Daniel Tizon (Microsoft Regional Director) came all the way from Switzerland

      • to Microsoft employee from Paris, Microsoft v –TSP,

      • or publised book author, Certified Microsoft, MSP students or enthusiasts GEEKS BIG ...

      They addressed various topics on Azure : Java , PHP, Zend Framework 2 , mobility, Ruby , Python, C #


      As far as I am concerned, not only was I busy organizing the event, I also presented 2 sessions as Microsoft vTSP (“virtual Technology Specialist”).


      imageimage

      I designed three tracks in // to address the needs avec everyone, and to ensure all can fit in one day !!
      (beginner, experts and CxOs)


      image

      VERY positive feedback.


       


      And the event have been many times covered by the media, such as Microsoft https://blogs.microsoft.fr/azure/assistez-au-global-windows-azure-bootcamp-le-samedi-29-mars-lyon.html


      or Programmez!


      also plenty of goodies and licences (cf images), etc…

      Wednesday, May 7, 2014

      Where to start with Microsoft Azure Enterprise Agreement and billing / cost ? (EA)

      UPDATE Sept 2016 : Here is the documentation released by Microsoft: https://eaportalonboardingvideos.blob.core.windows.net/onboardingvideos/AzureDirectEACustomerOnboardingGuide_En.pdf
      (download the file here)

      Hint Billing: http://blog.thavo.com/2016/10/cost-on-azure-where-to-start.html




      image
      Ever wonder what are the advantages of an Enterprise Agreement (EA), as opposed to “Pay-as-you-go” and 6/12-Month Plan ? apart from a costing standpoint with discounted prices, since you are buying more.
      This post presents some of the advantages, and how to configure the account.

      http://azure.microsoft.com/en-us/pricing/calculator/ 
      image
      Firstly, you will be able to create as many subscriptions as you want, so that it matches both Cost Center and enforces true separation between Development accounts and Production one (for instance).
      This done by the flexible following model based on 3 roles (Enterprise Administrator, Account Owner and Service Administrator). An easy to understand tutorial in few steps is made available (less steps if you are “only” Account Owner) in your EA portal (https://ea.windowsazure.com).

      image

      When you first login, you might receive this scary message. Check that the Microsoft Account you are using does not depend on other Azure Subscriptions (such as MSDN, etc...).







      TUTORIAL PAGE 1/3:
      image

      TUTORIAL PAGE 2/3
      image
      TUTORIAL PAGE 3/3 (with sample and static dummy data)
      image
      Now you are ready to create subscriptions, by clicking the “Add Subscription” in green below:
      image
      Now, let’s walk through the registration of a new subscription.
      Login and type in the information of the Account Owner:
      image  image
      DONE. Here is your new subscription. WARNING, a best practice consists in renaming the default “Enterprise” subscription name into a meaningful name that suits your business. Else, you will end-up having many subscription without know which one does what.
      To rename, click on “Enterprise”, i.e. the default subscription name.

      https://account.windowsazure.com/Subscriptions
      image
      In this page that relates to billing you will also be able to rename by click “Edit subscription details”
      image
      Suggestion of names’ format:
      • myCompany-myBusinessUnitA-EA-ProjectNameAA-Dev
      • myCompany-myBusinessUnitB-EA-ProjectNameBB-PreSales
      • myCompany-myBusinessUnitB-EA-ProjectNameBB-Prod

      In parallel, you will receive a confirmation email:
      image

      For companies using Microsoft Azure, when applicable under conditions of being a very closed partner with Microsoft, you could activate benefits when you declare your “DPOR” Microsoft partner, Digital Partner of Reference.
      Illustration :
      Let us assume that the DPOR is VISEO of ID=3398971 and that you are using the old Azure portal https://manage.windowsazure.com/ (easier to illustrate):
      https://portal.azure.com/#blade/Microsoft_Azure_Billing/managementpartnerblade?ID=3398971

      CAUTION : * You must be the owner of the subscription, i.e. the Enterprise Account Role “Account Owner
      * Microsoft is performing a rework to better improve the Billing on the Enterprise Agreement portal. These steps might not work in the near future

      1. Log in to the portal
      2. Click on your name/email
      3. Click “View my bill”
      SNAGHTML17ecfe5a
      4. It will redirect to another portal called “Azure Account Center" (sometimes it takes a few minutes, for secured login using Single Sign On) : https://account.windowsazure.com/Subscriptions
      5. Choose your subscription
      6. Select “Partner information”, then fill in the number 3398971. When you click “Check ID” Azure finds the corresponding DPOR.
      https://portal.azure.com/#blade/Microsoft_Azure_Billing/managementpartnerblade?ID=3398971

      image
      It will send an email to your DPOR (provided you have a subscription that has an explicit naming convention).

      _
      (Vincent THAVONEKHAM, Microsoft Practice Manager @VISEO Technologies)

      Friday, April 18, 2014

      How to enable Azure Multi-Factor Authentication for a specific tenant ID?

      What is that for and what is the need ?

      Philippe Guedez and I had the need to highly secure the access of a Web application that was developed on Microsoft Azure. To do so, we have used the Azure Multi-Factor Authentication (MFA) as part of the AAD (Azure Active Directory).

      Not only the login page is going to ask you your login/password as usual, it is going to send you a text message on your mobile phone with an additional code. You could also configure MFA to use other secure ways to authenticate.

      If you have an application, with a tenant id of say, 1477db05-0f2c-8924-904b-c87e8f0e928f, you’ll access to your configuration page by the following actions, which leads you to the URL (for example): https://account.activedirectory.windowsazure.com/usermanagement/multifactorverification.aspx?tenantid=1477db05-0f2c-8924-904b-c87e8f0e928f&culture=en-US

      MFA will enforce compliancy to rules and regulations that requires high auditing standards, such as NIST 800-63 level 3, HIPAA, PCI DSS.

      The various steps:
      STEP 1 : ACTIVATING MFA
      STEP 2 : ADD NEW MFA USER AND PASSWORD
      STEP 3 : LETS CONFIGURE THE ACCOUNT AS A NEW USER RECEIVING THE EMAIL
      STEP 4 : LET’S use the multi-factor authentication that is going to send me a text message

      APPENDIX 1 : Windows Azure MFA Admin portal (formally PhoneFactor)

      APPENDIX 2 : ALTERNATIVES: OLD FASHION RSA-SecurID way

      You could activate MFA for Azure or for Office 365: http://blogs.technet.com/b/ad/archive/2014/02/11/mfa-for-office-365-and-mfa-for-azure.aspx

      =====================

        STEP 1 : ACTIVATING MFA

      clip_image002

      You could exclude the constraints of MFA when the user is within the company given an IP range (it is in preview) :

      image

      The various roles that you could filter by:

      image

      To enable MFA:

      clip_image006

      clip_image008

      clip_image010

       

        STEP 2 : ADD NEW MFA USER AND PASSWORD

      You could add new users by activating the “Enable Multi-Factor Authentication” option.

      image

      image

      image

      Provide an email so that the end user could receive this temporary password, for first login.

      image

       

      STEP 3 : LETS CONFIGURE THE ACCOUNT AS A NEW USER RECEIVING THE EMAIL

      Enter the new account (use your temporary password):

      image

      Then, you’ll be forced to choose a proper and strong password

      image 

      image image

      Set-up the MFA that will use, for instance Mobile phones:

      image

      If you really don’t know what to do, you have a video to help you: http://channel9.msdn.com/posts/Multi-Factor-Account-Setup

      image

      image

      image

      Instantaneously, you will receive a text message “your Microsoft sign in verification code is above. Type this code into your application to continue.” with your code.

      image

      If you wait too long like me, when writing this blog! you’ll get this error message and ask you to resend a text message Clignement d'œil

      imageimage

      So let me start all over again ! and here are the next steps:

      image

      image

      Assume you want to generate for many apps: “Generate app password”

      app1: image other apps: image

       

       

        STEP 4 : LET’S use the multi-factor authentication that is going to send me a text message:

      Add your new AAD user as a co-administrator (see potential error messages)

      image

      log-out, and sign in with this new co-administrator, with the temporary password previously generated.

      image

      Enter the code sent to your mobile phone… then tada ! you start to log into your application with your new MFA !

      image

      THAT’S ALL ! Now you can clean up all Microsoft Account (LiveID) so that ONLY people managed in AAD (with all advantages) could connect your Azure developer Portal.

      image

      ============== T H E  E N D  ==============

       

      ============== A P P E N D I  C E S  ==============

      More information here: http://technet.microsoft.com/library/en-us/dn249471

      APPENDIX1 : Windows Azure MFA portal (formally PhoneFactor)

      image

      Where you could administer and configure the MFA. For instance here you could see a report that can be downloaded.or download the SDK corresponding to your programming language.

      image imageimage

      ALTERNATIVES: OLD FASHION RSA-SecurID way

      MFA supports token sent to your mobile phone. You could also use alternatively the "old fashion" way, if you want to secure via VPN and securID,

      image image image

      you could set-up a Azure VM protected by VPN, where have stored the login/password of your Web Application in the browser, or better in a secured safe.

       

      Note : you could change the Global administrator of your Microsoft Azure

      image

       

      ============== S O M E   E R R O R   M E S S A G E S  ==============

      Setting up AAD-MFA for Azure Administrators is relatively straight forward Joy of some errors:

      https://activedirectory.windowsazure.com/Interrupts/SignInAccessDenied.aspx

      image

       

      image

      image

      image

       

      Some links on a given user may result in this:

      image