AzureSimpleREST Module
Although Microsoft does a great job with their AzureRM Modul module, there are always reasons not to use these cmdlets. In most cases because they are slower than direct requests against the Azure REST API. In other cases because certain functionality has not yet been implemented.
The module AzureSimpleREST written by me positions itself in this gap
The module contains e.g. functions like “Get-AzSRVMProtectionStatus” which uses an officially documented REST Call, but I don’t know any AzureRM cmdlet that provides this function. So with the following command
Get-AzSRVMByName -SubscriptionId nnnnnnnn -VMName "vmname" | Get-AzSRVMProtectionStatus
possible to check if a virtual Machine is protected by Azure Backup.
How I came up with this REST method, I described in another blog entry.
Why write you own Module
I decided to create my own module because it makes things a lot easier. For example, I could include the great function ‘Get-AzureRmCachedAccessToken’ by Stéphane Lapointe and ‘Get-SubnetAddress’ by Dave Wyatt directly.
Both have published their code under the MIT license.
These functions e.g. use the login capability of the official AzureRM module and as a result no service principal is required. This makes it easier to get started.
Installation
You can find the module in the PowerShell Gallery and install it with Install-Module AzureSimpleREST -Scope Current User
.
Usage
All commands start with the abbreviation AzSR for Azure Simple REST.
There is also a help with examples for each cmdlet. Many of the cmdlets build on each other and can be connected by the PowerShell pipeline.
Subscription Management
Unlike the official AzureRM cmdlets, these cmdlets do not have a subscription context. The subscription Id must be passed if required. If you only work with one subscription and don’t want to specify it every time, you can use PSDefaultParameterValues.
$PSDefaultParameterValues=@{"*-AzSR*:SubscriptionId"="SubscriptionID"}
The command sets the default value for all cmdlets that expect the ‘SubscriptionId’ parameter to the one you defined. If you want to overwrite it you just have to specify the parameter.
$PSDefaultParameterValues=@{"*-AzSR*:SubscriptionId"="SubscriptionId#1"}
# Liefert alle VMs der SubscriptionId#1
Get-AzSRVMBySubscription
# Liefert alle VMs der SubscriptionId#2
Get-AzSRVMBySubscription -SubscriptionId SubscriptionId#2
Contribute
The complete module is also published under the MIT license on GitHub. Anyone can create a pull request and help to extend the module.
Next steps
Currently I am writing Pester tests for all functions. The goal is to only include functions that can be tested with a Pester test.
More about this in another blog entry.