You might be already using the Azure PowerShell DSC (Desired State Configuration) extension to manage the configuration for your Windows VMs in Azure today. Are you looking for the same way to manage the configuration of your Linux VM?
Several months ago, Microsoft released Windows PowerShell Desired State Configuration (DSC) for Linux. Today I'm happy to announce a new Azure Virtual Machine Extension – DSCForLinux Extension, which enables you to manage the configuration of your Linux VMs through DSC for Linux in Azure. You can now easily install DSC for Linux and push the MOF configuration to your Linux VM through this extension. The latest version of DSCForLinux Extension is 1.0, and GitHub location is here. Here is what exactly DSCForLinux Extension can do for you:
- Push MOF configurations to the Linux VMs (Push Mode)
- Distribute MOF configurations to the Linux VMs with Pull Servers (Pull Mode)
- Install custom DSC modules to the Linux VMs (Install Mode)
- Remove custom DSC modules to the Linux VMs (Remove Mode)
You can use DSCForLinux Extension with both Azure CLI and PowerShell. Set up your Azure CLI here and PowerShell here if you didn’t get them ready.
If this is the first time you use Azure VM Extensions, you can learn more from Azure Virtual Machine Extensions. To create MOF documents, please read Get started with Windows PowerShell Desired State Configuration for Linux and Built-In Windows PowerShell Desired State Configuration Resources for Linux.
Let’s give a quick example of how to apply a MOF configuration file in an Azure storage account to a Linux VM created in Azure Resource Manager mode using DSCForLinux Extension with both the Azure CLI and PowerShell. (For more complete documentation, including other usage examples and schema documentation, see the DSCExtension For Linux in Github.)
Using Azure CLI
1. Create the private configuration json file (protected.json) with following content:
{ "StorageAccountName": "", "StorageAccountKey": " ", "ContainerName": " ", "MofFileName": " " }
Create the public configuration json file (public.json) with following content:
{ "Mode": "Push" }
2.Switch to Azure Resource Manager mode by running:
$ azure config mode arm
3. Enable the extension by running:
azure vm extension setDSCForLinux Microsoft.OSTCExtensions --private-config-path protected.json --public-config-path public.json
Using Azure PowerShell
1.Login to Azure Resource Manager mode by running:
Login-AzureRmAccount
2.Enable the extension by running:
$rgName = '' $vmName = ' ' $location = ' ' $extensionName = 'DSCForLinux' $publisher = 'Microsoft.OSTCExtensions' $version = ' ' $privateConfig = '{ "StorageAccountName": " ", "StorageAccountKey": " ", "ContainerName": " ", "MofFileName": " " }' $publicConfig = '{ "Mode": "Push" }'
3. Set the extension to deploy the MOF file:
Set-AzureRmVMExtension -ResourceGroupName $rgName -VMName $vmName -Location $location ` -Name $extensionName -Publisher $publisher -ExtensionType $extensionName ` -TypeHandlerVersion $version -SettingString $publicConfig -ProtectedSettingString $privateConfig
You can start your journey using th DSCForLinux Extension right now using the GitHub documentation!
If you have any issue from using the DSCForLinux Extension, feel free to file the issue to us here.