Using GithubReleaseManager to automate GitHub releases

GitHubReleaseManager

GitHubReleaseManager is a PowerShell module that wraps up GitHub’s Releases API. It allows users to automate releases of their software by via the command line or by integrating the module in to build tools such as PSake.

About

The idea came about while working on another community project. Every release consisted of a number of manual tasks, one of which was publishing the release. While not complicated, it was always slightly tense for me as I wanted to ensure that all releases were consistent. The obvious solution was to automate this step and luckily, GitHub provide a really comprehensive API for managing releases. The module provides a way to create new releases and manage/update existing releases and assets.

In the future I will post more articles covering how to use each of the additional functions in the module.

Continue reading

Defining multiple Output Types in a function

Defining an Output Type for a function is a useful way to inform other users or tools about what to expect once the function has been executed.

While doing some research I came across the documentation for the OutputType attribute and noticed that it’s possible to set an Output Type per Parameter Set. You can use the ParameterSetName property in the declaration. For example:

[CmdletBinding(DefaultParameterSetName="A")]
[OutputType('[System.String]', ParameterSetName="A")]
[OutputType('[System.Array]', ParameterSetName="B")]

Param(
    
    [Parameter(Mandatory=$true, Position = 0, ParameterSetName="A")]
    [ValidateNotNullOrEmpty()]
    [String]$InputA,

    [Parameter(Mandatory=$true, Position=1, ParameterSetName="B")]
    [ValidateNotNullOrEmpty()]
    [String[]]$InputB     
)

The OutputType property of Get-Command reflects each type specified above:

Personally, when designing a function, I always try to ensure that it has a single purpose and will only return a single type. However, in the case where this is unavoidable and you are using Parameter Sets to categorise your parameters this is a neat way to do the same with your Output Types.

Quickly list supported API versions for ARM resource types

One of the things that I found the most challenging when learning how to create Resource Manager templates was trying to understand which API versions to use for my resources. The documentation is pretty clear and states that most of the time we should be aiming for the latest API version. It also contains examples showing how to get the information. For example:

((Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Web).ResourceTypes | Where-Object ResourceTypeName -eq sites).ApiVersions

Excellent.. but copying and editing the code every time I wanted to retrieve some information was time-consuming. So to make things easier I threw together a small function that lives in my PowerShell profile. It will return a list of current supported API versions for given resource type (just like the code above). However the main difference is that when I need to query a resource I can just run the following command in my session:

Get-AzureRMResouceTypeAPIVersion -ProviderNamespace "Microsoft.Network" -ResourceTypeName "loadBalancers"

Here is the code:

While the function is nothing special, it demonstrates how building your own tools around existing functionality can speed up your learning and development processes.

Automating Azure Disk Encryption with PowerShell

While studying for the 70-533 exam I decided to take a deep dive in to the Disk encryption feature provided by Azure. Azure Disk Encryption uses BitLocker for Windows or DM-Crypt for Linux enabling users to encrypt OS and data disks of Azure Virtual Machines.

It turns out that it’s not just as simple as flicking a switch to get encryption up and running. The service is tied in with Azure Active Directory and Key Vault too. After manually running through the set up a few times I decided to put together a proof of concept script based on client-secret authentication. It’s worth noting that certificate-based authentication is also supported.

Continue reading

Announcing PowervRA v2.0.0!

Today, we are pleased to announce the release of PowervRA v2.0.0!

One of the biggest changes in this release is support for PowerShell Core. I’ve got to tip my hat to the PowerShell team and the community members that have contributed for doing a sterling job so far. Considering the project is only in its alpha phase at the moment it’s it pretty good shape!

In the following post I’m going to cover PowerShell Core support, some interesting news about Docker and try to give a bit of context around our module restructure. For a full list of changes, check out the changelog.

Continue reading