Archive | Azure Automation

Monitor Azure DSC in Azure Automation with Azure Log Analytics

Recently it became possible to monitor Azure DSC in Azure Automation with Log Analytics. Here is how to do this setup in the Azure Portal.

First go to the Log Analytics workspace and click on Azure Resources. Select the Automation Account where DSC exists.

Monitor Azure DSC in Azure Automation with Azure Log Analytics 1

Select DscNodeStatus and click Save. In my example, I also want information about jobs in Azure Automation.

Monitor Azure DSC in Azure Automation with Azure Log Analytics 2

Verify that you have nodes added for Azure DSC and then go to Search in Log Analytics.

Monitor Azure DSC in Azure Automation with Azure Log Analytics 3

Do a search for Category=DscNodeStatus and you will see information from Azure DSC.

Monitor Azure DSC in Azure Automation with Azure Log Analytics 4

For more information and to do this in PowerShell, see the following documentation page: https://docs.microsoft.com/en-us/azure/automation/automation-dsc-diagnostics

0

Keep service running with DSC on Windows Server

If you are in the need for keeping a service running or if you have a service that doesn’t start when you reboot your server, DSC in Azure Automation could be the thing for you!

In this post I will show how easy it is to create a DSC configuration that you can import, compile and then use on your servers. This off course works well both in on-premises datacenters as well as in Azure or any other public cloud provider.

Edit the following code and change the service you want to have started and save it to a PowerShell ps1-file (Example: MyDSC.ps1).

Create an Azure Automation Account and click on it.

Click DSC Configuration and then Add a configuration up to the left of the portal. Import the file created.

Keep service running with DSC on Windows Server 1

Click on the DSC Configuration in the portal and then Compile. When the compile is Completed you can start to use the configuration.

Keep service running with DSC on Windows Server 3

Click DSC Nodes and add the server you want to use DSC on.

Keep service running with DSC on Windows Server 2

Select if you want to deploy the configuration on an Azure VM och on-prem VM.

Keep service running with DSC on Windows Server 4

0

DSC for Linux example – application installation and configuration with bash script

In the following example I will show how to install the “ocsinventory-agent” package on an Ubuntu server and then pull the Inventory on the server to a file in a created directory “/var/log/ocsinventory”. This will be done by a bash script. The DSC configuration works fine but is still under testing so please give me feedback if something could be done in another way. It is tested with Azure Automation DSC as a pull server.

DSC Configuration file

Just copy and pasted the script to a PowerShell file (ps1).

 

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