Never forget -Verbose again

by Donovan Brown 29. November 2014 07:05

Working with DSC I am constantly having to type –Verbose on my Start-DscConfiguration calls.  However, I stumbled across this cool feature of PowerShell that I thought I would share that will set the –Verbose switch on all your calls for you.

PowerShell has a collection of Preference Variables that allow you to customize its behavior.  One such variable is named $VerbosePreference. By default the value of $VerbosePreference is “SilentlyContinue” which requires you to supply the –Verbose switch to see any verbose messages written by the cmdlet or function calls.  However, if you simply set:

$VerbosePreference = “Continue”

You can now forego passing the –Verbose switch but all the verbose messages will be displayed.  This combined with the positional Path parameter can drastically reduce the amount of typing for Start-DscConfiguration call.

Before:

Start-DscConfiguration –Wait –Verbose –Path .\Test

After:

Start-DscConfiguration .\Test –Wait

Or you can go that extra mile and create a new Alias for Start-DscConfiguration:

New-Alias –Name sdsc –Value Start-DscConfiguration

Then all you have to type is:

sdsc .\test -Wait

Like all variables, the values that you set are specific to the current Windows PowerShell session. However, you can add them to your Windows PowerShell profile and have them set in all Windows PowerShell sessions.

Tags: , , , ,

Work

PowerShell Desired State Configuration (DSC) Journey by Jacob Benson

by Donovan Brown 28. November 2014 21:08

I just wanted a list of all the post in one place.

PowerShell Desired State Configuration (DSC) Journey by Jacob Benson:

Tags: , ,

Work

How to use VSO and RMO to deploy an Azure Website

by Donovan Brown 21. November 2014 11:06

This is a neat post because we are going to be using all three Azure offerings SaaS, PaaS and IaaS.  Let me set the stage.  My goal is to deploy using Release Management Online (SaaS) to an Azure Web Site (PaaS) via an Azure Virtual Machine (IaaS) from code in Visual Studio Online (SaaS).

First let's create the Azure Virtual Machine we are going to use to actually move the bits.  You will see why this is necessary as we progress. Please note this machine could live anywhere I just decided to place it in Azure.

When I create virtual machines in Azure I prefer to create the Cloud Service and Storage Account that is going to hold it first so that I can control the names. If you simply use the Virtual Machine wizard it will create a Cloud Service and Storage Account with crazy names.  So let’s create our Cloud Service first.

Log into your Azure account at https://manage.windowsazure.com and click the “New” button and select Compute -> Cloud Service -> Quick Create.

Enter in a descriptive name and click Create.

Next we will create the Storage Account. Click the “New” button again and select Data Services -> Storage -> Quick Create.  Enter in a descriptive name (I use the same as the Cloud Service name) select the Location and Replication that fits your needs. I selected South Central US (because I live in Texas) and Locally Redundant. Now click “Create Storage Account”.

Now let’s create our Virtual Machine.  Click the “New” button again and select Compute -> Virtual Machine -> From Gallery. Select the “Windows Server 2012 R2 Datacenter”. Enter in a descriptive name, leave the size as an A1 and enter in a User Name and Password.

On the Virtual machine configuration page select the Cloud Service and Storage Account we created earlier.  Click through the final pages to create the virtual machine.  While the machine is being created we can move on to creating the web application we will deploy to an Azure Website.

I am using Visual Studio 2015 Preview.  If you are using an older version of Visual Studio make sure you have the latest version of the Azure SDK installed.  This will allow us to configure the Azure Website in the New Project dialog in Visual Studio.

Start Visual Studio and connect to your Visual Studio Online account with Team Explorer.  Now create a new ASP.NET Web Application and make sure you check the box to “Add to source control”.  On the “New ASP.NET Project” page make sure the “Host in the cloud” check box is checked and “Website” is selected.

On the “Configure Microsoft Azure Website” dialog enter a Site name and select “Create new server” for the Database server.  Enter a database username and password then click OK.

We need to add a PowerShell file to our new project that will be used by Release Management to deploy our project.  We will store the file in a new folder called “Configuration”.  To the new “Configuration” folder add a text file named “publish.ps1”.  Right click on the “publish.ps1” file in Solution Explorer and select Properties.  Change the “Copy to Output Directory” to “Copy Always”.  Now type the following command into the file replacing the [] values with your values:

Publish-AzureWebsiteProject -Name [AzureWebsiteName] 

-Package $applicationPath\_PublishedWebsites\[ProjectName]_Package\[ProjectName].zip

Now check in the project.

Now we need to configure our build.  From Team Explorer create a new “Build Definition”.  You should only have a single working folder. The “Source Control Folder” should be the folder that contains your solution file and the “Build Agent Folder” should simply be “$(SourceDir)”.  The build controller should be “Hosted Build Controller” and the “Copy build output to the server” should be selected on the “Build Defaults” page.

To make sure the deployment package is created correctly so it can be used by Release Management we need to pass additional arguments to MSBuild.  In the MSBuild Arguments field enter:

/p:DeployOnBuild=True /p:AutoParameterizationWebConfigCOnnectionStrings=False

Now Save and Queue a new build.  While the build is running we can go configure our virtual machine with the Azure PowerShell tools.

Connect to the Virtual Machine we created earlier.  Download and install the Azure PowerShell and Web Deploy 3.5 tools from here.  There is a great write up on how to set up the Azure PowerShell tools here. Once you connect your subscription you can log off the machine.

You will have to have the Release Management Client Update 4 installed on a machine and connected to your Visual Studio Online account.

We now have to connect Release Management to your Azure Account.  From the Administration tab click on “Manage Azure”.  Click the New button to open the “New Azure Subscription” page.  Use any name you like.  You can locate your “Subscription ID” from the Azure Management Portal.  From the Azure Management Portal select “Settings”. The settings page list all your Subscriptions with their Subscription ID’s.  Just copy and paste the GUID into Release Management. Next you will need to get your “Management Certificate Key” from https://manage.windowsazure.com/publishsettings. Just save the file to somewhere safe and open it with a text editor. Copy the ManagementCertificate value without the quotes and paste into Release Management.  Finally you need to provide a Storage Account Release Management will use to move files to Azure.  You can use the same Storage Account we created to hold our virtual machine.

With your Azure account configured in Release Management we can now create our Environment.  Click the “New vNext Azure” button on the Environments tab under “Configure Paths”. Then click “Link Azure Environment”. Select your subscription and select the storage account we created and click Link. Now click "Link Azure Servers", select our virtual machine and click Link. You can now Save & Close the Environment.

Next we have to create the “vNext Release Path” using our new environment. Using the environment we just created add as many stages as you need. This machine is really playing the role of a proxy.  The bits of our build will be copied there and the PowerShell we be executed from that machine. The PowerShell will publish our application to the Azure Website.

Next we need to define a component.  From the “Configure Apps” tab select “Components”.  Click “New vNext” and give it a name and set the “Path to package” to “\”.  Now Save & Close.

The final step is creating a “vNext Release Template”. Click “New” from the “vNext Release Templates” page.  Give it a name, select the release path we just created and set the build definition to the correct build then click Create.  Right click on Components in the Toolbox and click Add.  Link the component to the Release Template.  Now drag the “Deploy Using PS/DSC” to the Deployment Sequence. Select the server name from the dropdown.  Enter the username you selected when you created the virtual machine in .\UserName format.  Enter the password, select the component, set PSScriptPath to “Configuration\publish.ps1” and set SkipCaCheck to “True”.  Now click Save and then “New Release”.  Use the latest build and select Start.

You application will now be deployed to your Azure Website.

Tags: , , , , , ,

Work

How to deploy the Fabriakam Call Center application with DSC

by Donovan Brown 21. November 2014 01:32

Because there is not an Update 4 version of the Keller VM using the Visual Studio 2013 Update 3 Keller VM I will show you how to upgrade Release Management to Update 4 and create a vNext deployment for the Fabriakam Call Center application.

First we have to uninstall Release Management Update 3. Log in as Brian Keller and uninstall the components in the following order:

  1. Deployer
  2.  Client
  3. Server

You will get an error during the uninstall of the server just click Close the program.

Now download Update 4 of Release Management iso image from VisualStudio.com and mount the image to your VM.

Install the components in the following order:

  1. Server: password for Administrator is P2ssw0rd
  2.  Client: enter “vsalm” for Release Management service
  3. Deployer: password for Administrator is P2ssw0rd

Upgrading just Release Management to Update 4 without the rest of the system will break build.

The work around is to copy Microsoft.VisualStuio.Services.Common.dll and Microsoft.VisualStuio.Services.WebApi.dll from “C:\Program Files (x86)\Microsoft Visual Studio 12.0\Release Management\Client\bin” to “C:\Program Files\Microsoft Team Foundation Server 12.0\Tools”.  Make sure restart the build service after you copy the files.

The shortcut pinned to the Taskbar for the Release Management Client will be broken so fix it to point to the next installation of Release Management.

To use DSC to deploy your application you have to make sure your DSC script is in the drop location so let’s address that first.  Open the FabrikamFiber.CallCenter solution and add a Configuration folder to the FabrikamFiber.Web project.

This folder will contain all the DSC scripts we need to deploy our project using DSC.  Right click on the Configuration folder and select Add / New Item.  Add a new text file named “install.ps1”.  From the Solution Explorer right click “install.ps1” and select Properties.  Change the “Copy to Output Directory” to “Copy always”.  This will ensure the file ends up in the drop location.  Enter the following text into install.ps1

Configuration InstallWebSite
{
   Node $env:COMPUTERNAME
   {
      WindowsFeature InstallIIS
      {
         Name = "Web-Server"
      }

      WindowsFeature AspNet45
      {
         Name = "Web-Asp-Net45"
      }

      File CopyBits
      {
         DestinationPath = $DestinationPath
         SourcePath = $applicationPath
         Type = "Directory"
         Recurse = "True"
      }
   }
}

InstallWebSite

This is the DSC configuration that will ensure that IIS and ASP.net 4.5 are installed and copy the files to the server.  The variable $DestinationPath will be defined on the component in Release Management and $applicationPath will be provided to the script from Release Management.

Now check in your changes and queue a new build disabling tests. Make sure the build passes and open Release Management.

The only way to add a new vNext server is by creating an Environment so let’s begin there.  Click “Configure Paths” then “Environments”. Using the new menu select “New vNext: Standard”.

Enter the following values:

  • Name: DSC-Dev
  • Owner: Brian Keller
  • Description: Development environment for Web Team for internal apps using DSC.

Now click the Create button under the Servers Tab.  We are going to be deploying to the VM which is named VSALM.  The DNS Name must contain the port to use to establish a PowerShell Remote connection. The default port for PowerShell Remoting is 5985.

  • Name:  VSALM
  • DNS Name: VSALM:5985
  • Owner: Brian Keller

Click Save & Close the Server dialog and click Save & Close on the Environment.  Repeat this process for each environment linking to the same machine.

Now we have to create vNext Release Path.  Click “vNext Release Paths” then New.Name:

  • Fabrikam Call Center DSC
  • Description: Release path for the call center app using DSC.

Add a stage.

  • Stage: Dev
  • Environment: DSC-Dev
  • Automated: <Checked>
  • Approver: Web Team
  • Owner: Web Team
  • Validator: Web Team
  • Approver: Brian Keller

Repeat this process for each stage of your deployment.  When you are done Save & Close the Release Path.

Now move to the “Configure Apps” tab so we can configure our vNext Components on the Components tab. From the New menu select “New vNext”.

  • Name: Fabrikam Call Center DSC
  • Builds with application: <Checked>
  • Path to package: _PublishedWebsites\FabrikamFiber.Web

Click “Configuration Variables” tab and Add a new configuration variable.

  • Name: DestinationPath
  • Type: Standard

Now Save & Close your component.

The final step is to create a vNext Release Template. Click New on the “vNext Release Templates” tab.

  • Name: Fabrikam Call Center DSC
  • Description: Call Center DSC
  • Release Path: Fabrikam Call Center DSC
  • Build definition: vsalm:8080/FabrikamFiber/Nightly Fabrikam (Dev)
  • Can Trigger a Release from a Build: <Checked>

Click Create.

Right click on Components in the Toolbox and link your component.

To build your Deployment Sequence simply drag the “Deploy Using PS/DSC” on to the Deployment Sequence. Expand the action and use the following values

  • ServerName: VSALM
  • UserName: .\Administrator
  • Password: P2ssw0rd
  • ComponentName: Fabrikam Call Center DSC
  • PSScriptPath: Configuration\install.ps1
  • SkipCaCheck: True

Leave the rest of the values empty.

Under “Custom configuration” add a new “Standard Variable” and select “DestinationPath” set the value to “c:\FabrikamRM\WebSite\DEV”.

Copy and paste the sequence to the QA stage and change the value of the DestinationPath variable to “c:\FabrikamRM\WebSite\UAT” and repeat to the Prod stage using  “c:\FabrikamRM\WebSite\PROD”.

Click Save then click “New Release”. Use the latest version of the build and click Start.

Good luck! If you have any questions feel free to ask me on Twitter @DonovanBrown

install.ps1 (438.00 bytes)

Visual Studio 2013 Update 3 Keller VM share issue

by Donovan Brown 20. November 2014 22:43

Problem:

When I attempt to open the drop folder of a build on the Update 3 version of the Visual Studio 2013 Keller vm I get the follow error.

Solution:

Give Everyone read permission to the c:\ffdrops folder.

If you get promoted by a Network discovery and file sharing dialog select "Yes, turn on newtork discovery and file sharing for all public networks?".

Tags: ,

Work

Trigger a vNext Release from team build

by Donovan Brown 18. November 2014 19:18

Using Release Management you can implement true Continuous Delivery.  With the latest update of Release Management you can trigger a release via a REST api call to Release Management.  In this post I will share the script and build definition I used to trigger the release and how to use them in your team build.

Although team build now allows us to run PowerShell scripts as part of our build we are still forced to create a custom build template.  The reason being the two opportunities provided by the default template are at the wrong points during the build.  We can run a PowerShell either before or after the build.  However, we need to run a PowerShell after the drop of the files. So the attached build template adds the ability to run a PowerShell after the files are copied to the drop location.

To use the ps1 and build template in your build they must be stored in TFS. So pick a location and check the files into TFS.  The files do not have to be stored together. We will use these server paths when we configure our build.

To create a new build definition using the build template attached just create a build like normal.  Once on the Process tab select the Show details button and click the New… button.  Use the Browse dialog to locate the new build template in TFS and click OK.  With the Trackyon.1.0.xaml selected you will have additional features most importantly for this post the “Post-drop script arguments” and “Post-drop script path”.  The value for “Post-drop script arguments” are Release Management Server name, Release Management Server Port, Team Project and Target Stage each separated by a space.  For example in the image below my Release Management Server name is “DemoDC” running on port 1000, my team project is “Scrum” and I want to target the “QA” stage of my release path.  The value for “Post-drop script path” is the server path to the trigger.ps1 file.


 

Now all you have to do is start your build to have it trigger a release in Release Management

Before I end this post I would like to touch on some challenges I faced with trying to use the REST api for Release Management.

One issue that was very difficult to troubleshoot was the requirement that the URL of TFS configured in Release Management on the Manage TFS tab must match exactly to the URL passed in by the script.  However, the value stored in $env:TF_BUILD_COLLECTIONURI used in the script is read from the Server URL in the Team Foundation Server Administration Console.  If those values do not match the release will fail.  You can use the Change URLs link in the Team Foundation Server Administration Console to change the Server URL so it matches the one in Release Management.

Just as a tip make sure you have Fiddler installed because the error messages from the REST api or not very informative.  I had to use Fiddler a couple of times to troubleshoot issues.

Trigger.ps1 (2.78 kb)

Trackyon.1.0.xaml (48.84 kb)

Tags: , , ,

Work

How to run Microsoft Test Manager Suite in vNext Deployment

by Donovan Brown 18. November 2014 18:08

While preparing to speak at TechEd Europe I really had to run Release Management and Desired State Configuration (DSC) through their paces. I already blogged about one of my challenges of implementing tokenization in a DSC based deployment here

I also wanted to run Coded UI tests as part of my release.  To do this I simply ran the attached PowerShell script during my release.  The script is very similar to the tool I wrote for the Agent based deployment here

In this post I simply share the ps1 file that is attached and explain how to add it to your pipeline.  For this post I will be using Update 4 of Release Management.

The first thing you have to do is make sure the ps1 file is in the drop location of your team build.  There are several ways you can do this, however, I simply added a Configurations folder to my Coded UI Test project in Visual Studio.  The most important part is to make sure that “Copy to Output Directory” is set to either “Copy if newer” or “Copy always”. This will ensure the file is in the drop location of the build.

Now queue a build and examine the drop location. You will need to know the relative path from the root of the drop location of your ps1 script for use in your “Deploy Using PS/DSC” action of your vNext Release Template.

Now let’s add a new vNext component in Release Management.  Select the “Builds with application” radio button and simply enter a “\” for the value.

On the “Configuration Variables” tab you have to setup all the parameters for the ps1 file. Add each variable as a Standard configuration variable (Collection, TeamProject, PlanId, SuiteId, ConfigId BuildDirectory, TestEnvironment, Title and TestRunWaitDelay). You can refer to my previous post on where to locate the values for each configuration variable.  One of the new features of Update 4 is the ability to define default values for variables that do not change very often.  As you can see in the image below I set default values for Collection, TeamProject, TestEnvironment and TestRunWaitDelay.

With our component created we can move on to the vNext Release Template.  Create a new one and add your components.  Now drag the “Deploy Using PS/DSC” action onto the deployment sequence.  Select the desired server from the ServerName dropdown. That server must already have a Test Agent configured on that machine with tcm.exe.  The UserName and Password that are provided is an account that has permission to establish a Remote PowerShell connection to the target machine.  Please note that in Update 3 of Release Management this is NOT the account that will execute your ps1. The ps1 in Update 3 is run by local system.  Which means for this to work local system must have access to your TFS or you will get an access denied error.  Select your test component in the ComponentName dropdown.  Now enter the relative path to the ps1 file in the drop location.  You can leave the rest of the values blank.

We now have to add the Custom configuration variables to the action.  Click the plus button or use the down arrow and select “Standard variable”.  On the newly added row select the configuration variable you want to set and enter the correct value.  For the BuildDirectory variable enter “$applicationPath”. This variable is provided by Release Management and points to a location that contains the files of our component.

Now you should be able to run a new release and execute automated test.

RunTests.ps1 (4.94 kb)

Tags: , , , , ,

Work

How to access my OneDrive for Business on my Windows phone

by Donovan Brown 17. October 2014 18:35

Problem:

I want to be able to access my OneDrive for Business account on my Windows Phone. However, in the store I can only find the OneDrive application that is for my personal OneDrive account.  

Solution:

Open the Office application and swipe to “places”.  At the bottom you will see Office 365.  

Click that link and log into your corporate account.  After you do you will now have access to your OneDrive for Business files from within the Office application.

 

Tags: , , ,

Work

Why is my Visual Studio 2013 Command Prompt impossible to find on Windows 8

by Donovan Brown 13. October 2014 01:06

Problem:

I can’t find the Visual Studio 2013 Developer Command Prompt!

Solution:

Press the Windows key and type "Visual Studio" on the Start screen, and then select "Visual Studio Tools". This will open a File Explorer that contains the command prompt.  Do yourself a favor and right click the item and select "Pin to Start" so you never have to search for it again!

Tags:

Work

Where are my diagnostic build logs?

by Donovan Brown 12. October 2014 22:00

Problem:

I am trying to customize TfvcTemplate.12.xaml and can’t increase the verbosity level any longer.

Solution:

Open the desired build and click the Diagnostics menu and select View Logs.

Explanation:

In the past there was an argument on the build template that allowed you to control the output verbosity.  However, in the new template that argument has been removed and is hardcoded to “Normal” on the call the msbuild.  Nevertheless, the data is being captured in the logs placed in the drop location.

Simply double click on the xml files.  If you are prompted for how to open the file select Internet Explorer.  There is an xsl file that will format the data making it easy to read in Internet Explorer.

You can read more here.

Tags: , , ,

About the author

My name is Donovan Brown and I am a Technology Specialist for DevTools with Microsoft with a background in application development.  I also run one of the Nation’s fastest growing online registration sites for motorsports events DLBRacing.com.  When I am not writing software I race cars for fun.  DLBRacing.com has given me the opportunity to combine my two passions writing software and racing cars.

AdSense

Month List

AdSense