Archive | Azure

Remove Azure Classic Blobs that are in Leased State “Leased” and Lease Status “Locked”

In this post I will post the PowerShell commands you can run to remove a blob file in an Azure Classic storage container that are in Leased State Leased and Lease Status Locked. There are some scripts out there to set all the files to Broken Lease State but this commands will only do it to one blob at the time.

Remove Blobs that are in Leased State Leased and Lease Status Locked 1

Picture 1: Shows a blob at Lease Status “Locked” and Lease State “Leased”.

Script to change the at Lease Status “Unlocked” and Lease State “Broken”.

Remove Blobs that are in Leased State Leased and Lease Status Locked 2

Picture 2: Shows a blob at Lease Status “Unlocked” and Lease State “Broken”.

To remove the blob with PowerShell one can run the following commands.

 

0

Install Desired State Configuration on Linux system and connect it to Azure Automation

I received a question if it is possible to only install DSC for Linux servers without installing OMS agent as I do in my post Easy installation and registration script for OMS and DSC on Linux.

To install PowerShell DSC manually it is just to download the Open Management Infrastructure (OMI) agent from https://collaboration.opengroup.org/omi, and then PowerShell DSC from https://github.com/Microsoft/PowerShell-DSC-for-Linux.

But what if you want to install the components by a script? On the web there is a couple of ways to do this and this is my way. In my script I will download the OMS agent and then use the OMI package in there to install OMI that is needed for DSC on Linux. This is because there is no way to download the OMI package from OpenGroup with wget.

The script is using dpkg as installer and is tested on Debian and Ubuntu. To use it on systems that support rpm packages, change the dpkg and .deb files.

 

0

Add module in Azure Automation if DSC Configuration compilation fails

If you get the following error, see below, when compiling DSC Configuration in Azure Automation, it is probably because the module for the DSC Configuration is missing. In my example I need the “nx” module to compile the DSC configuration file. To solve the problem, add the module to the Azure Automation account.

Add module in Azure Automation if DSC Configuration compilation fails 1

Exception calling “NewScriptBlock” with “1” argument(s): “At line:4 char:5 + Import-DSCResource -Module nx + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The DSC engine could not load the module ‘nx’. It was not found on the system. At line:8 char:9 + nxPackage apache2Install + ~~~~~~~~~ Undefined DSC resource ‘nxPackage’. Use Import-DSCResource to import the resource. At line:15 char:9 + nxService apache2Service + ~~~~~~~~~ Undefined DSC resource ‘nxService’. Use Import-DSCResource to import the resource. At line:23 char:9 + nxFile apache2File + ~~~~~~ Undefined DSC resource ‘nxFile’. Use Import-DSCResource to import the resource.” (At line:4 char:5 + Import-DSCResource -Module nx + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The DSC engine could not load the module ‘nx’. It was not found on the system. At line:8 char:9 + nxPackage apache2Install + ~~~~~~~~~ Undefined DSC resource ‘nxPackage’. Use Import-DSCResource to import the resource. At line:15 char:9 + nxService apache2Service + ~~~~~~~~~ Undefined DSC resource ‘nxService’. Use Import-DSCResource to import the resource. At line:23 char:9 + nxFile apache2File + ~~~~~~ Undefined DSC resource ‘nxFile’. Use Import-DSCResource to import the resource.)

Add Module

Open the Azure Automation account and click Asset and then Modules.

Add module in Azure Automation if DSC Configuration compilation fails2

If you have a module package you can upload it to Azure Automation by clicking “Add a module” if it exists in the Gallery, you can download and install it from there. In my example I will click “Browse Gallery” and install it from there.

Add module in Azure Automation if DSC Configuration compilation fails3

Search for the module to install. In my example “nx”.

Add module in Azure Automation if DSC Configuration compilation fails4

Click the module to install and then “Import”.

Add module in Azure Automation if DSC Configuration compilation fails5

Now the module should be installed into the Azure Automation account and be ready to use.

Add module in Azure Automation if DSC Configuration compilation fails6

Try to compile the DSC Configuration file again to see if it works!

 

 

0

Create an Azure Automation DSC Configuration with PowerShell

This is a short introduction on how you can create an Azure Resource Group, Azure Automation Account and DSC configuration with PowerShell.

The first one need is a DSC configuration file to upload into the DSC Configuration. In this example I will use an DSC Configuration file with configuration for the IIS role. To try this, save the following script as a PowerShell ps1 file as C:\DSC\IISFeature.ps1.

To create a Resource Group, Azure Automation Account and DSC Configuration with PowerShell run the following.

0