Allow the owner of the Azure Virtual Machines to configure the VM using Windows PowerShell Desired State Configuration (DSC) for Linux.
Latest version is 1.0.
About how to create MOF document, please refer to below documents.
- Get started with Windows PowerShell Desired State Configuration for Linux
- Built-In Windows PowerShell Desired State Configuration Resources for Linux
DSCForLinux Extension can:
- Push MOF configurations to the Linux VM (Push Mode)
- Distribute MOF configurations to the Linux VM with Pull Servers (Pull Mode)
- Install custom DSC modules to the Linux VM (Install Mode)
- Remove custom DSC modules to the Linux VM (Remove Mode)
Here're all the supported public configuration parameters:
MofFileUri
: (optional, string) the uri of the public MOF fileResourceZipFileUri
: (optional, string) the uri of the custom resource ZIP fileResourceName
: (optional, string) the name of the custom resource moduleMode
: (optional, string) the functional mode, valid values: Push, Pull, Install, Remove. If not specified, it's considered as Pull mode.
Here're all the supported protected configuration parameters:
StorageAccountName
: (optional, string) the name of the storage account that contains the fileStorageAccountKey
: (optional, string) the key of the storage account that contains the fileContainerName
: (optional, string) the name of the container that contains the fileMofFileName
: (optional, string) the name of the MOF file in the Azure Storage AccountResourceZipFileName
: (optional, string) the name of the custom resource ZIP file in the Azure Storage Account, the format should be "name_version.zip".
You can deploy it using Azure CLI, Azure PowerShell and ARM template.
2.1. Using Azure CLI
Before deploying DSCForLinux Extension, you should configure your public.json
and protected.json
, according to the different scenarios in section 3.
The Classic mode is also called Azure Service Management mode. You can switch to it by running:
$ azure config mode asm
You can deploy DSCForLinux Extension by running:
$ azure vm extension set <vm-name> DSCForLinux Microsoft.OSTCExtensions <version> \
--private-config-path protected.json --public-config-path public.json
To learn the latest extension version available, run:
$ azure vm extension list
You can switch to Azure Resource Manager mode by running:
$ azure config mode arm
You can deploy DSCForLinux Extension by running:
$ azure vm extension set <resource-group> <vm-name> \
DSCForLinux Microsoft.OSTCExtensions <version> \
--private-config-path protected.json --public-config-path public.json
NOTE: In ARM mode,
azure vm extension list
is not available for now.
2.2. Using Azure PowerShell
You can login to your Azure account (Azure Service Management mode) by running:
Add-AzureAccount
And deploy DSCForLinux Extension by running:
$vmname = '<vm-name>'
$vm = Get-AzureVM -ServiceName $vmname -Name $vmname
$extensionName = 'DSCForLinux'
$publisher = 'Microsoft.OSTCExtensions'
$version = '<version>'
# You need to change the content of the $privateConfig and $publicConfig
# according to different scenarios in section 3
$privateConfig = '{
"StorageAccountName": "<storage-account-name>",
"StorageAccountKey": "<storage-account-key>",
"ContainerName": "<container-name>",
"MofFileName": "<mof-file-name>"
}'
$publicConfig = '{
"Mode": "Push"
}'
Set-AzureVMExtension -ExtensionName $extensionName -VM $vm -Publisher $publisher `
-Version $version -PrivateConfiguration $privateConfig `
-PublicConfiguration $publicConfig | Update-AzureVM
You can login to your Azure account (Azure Resource Manager mode) by running:
Login-AzureRmAccount
Click HERE to learn more about how to use Azure PowerShell with Azure Resource Manager.
You can deploy DSCForLinux Extension by running:
$rgName = '<resource-group-name>'
$vmName = '<vm-name>'
$location = '<location>'
$extensionName = 'DSCForLinux'
$publisher = 'Microsoft.OSTCExtensions'
$version = '<version>'
# You need to change the content of the $privateConfig and $publicConfig
# according to different scenarios in section 3
$privateConfig = '{
"StorageAccountName": "<storage-account-name>",
"StorageAccountKey": "<storage-account-key>",
"ContainerName": "<container-name>",
"MofFileName": "<mof-file-name>"
}'
$publicConfig = '{
"Mode": "Push"
}'
Set-AzureRmVMExtension -ResourceGroupName $rgName -VMName $vmName -Location $location `
-Name $extensionName -Publisher $publisher -ExtensionType $extensionName `
-TypeHandlerVersion $version -SettingString $publicConfig -ProtectedSettingString $privateConfig
2.3. Using ARM Template
The sample ARM template is 201-dsc-linux-azure-storage-on-ubuntu and 201-dsc-linux-public-storage-on-ubuntu.
For more details about ARM template, please visit Authoring Azure Resource Manager templates.
protected.json
{
"StorageAccountName": "<storage-account-name>",
"StorageAccountKey": "<storage-account-key>",
"ContainerName": "<container-name>",
"MofFileName": "<mof-file-name>"
}
powershell format
$privateConfig = '{
"StorageAccountName": "<storage-account-name>",
"StorageAccountKey": "<storage-account-key>",
"ContainerName": "<container-name>",
"MofFileName": "<mof-file-name>"
}'
public.json
{
"MofFileUri": "<mof-file-uri>"
}
powershell format
$publicConfig = '{
"MofFileUri": "<mof-file-uri>"
}'
protected.json
{
"StorageAccountName": "<storage-account-name>",
"StorageAccountKey": "<storage-account-key>",
"ContainerName": "<container-name>",
"MofFileName": "<meta-mof-file-name>"
}
public.json
{
"Mode": "Pull"
}
powershell format
$privateConfig = '{
"StorageAccountName": "<storage-account-name>",
"StorageAccountKey": "<storage-account-key>",
"ContainerName": "<container-name>",
"MofFileName": "<meta-mof-file-name>"
}'
$publicConfig = '{
"Mode": "Pull"
}'
public.json
{
"MofFileUri": "<meta-mof-file-uri>",
"Mode": "Pull"
}
powershell format
$publicConfig = '{
"MofFileUri": "<meta-mof-file-uri>",
"Mode": "Pull"
}'
protected.json
{
"StorageAccountName": "<storage-account-name>",
"StorageAccountKey": "<storage-account-key>",
"ContainerName": "<container-name>",
"ResourceZipFileName": "<resource-zip-file-name>"
}
public.json
{
"Mode": "Install"
}
powershell format
$privateConfig = '{
"StorageAccountName": "<storage-account-name>",
"StorageAccountKey": "<storage-account-key>",
"ContainerName": "<container-name>",
"ResourceZipFileName": "<resource-zip-file-name>"
}'
$publicConfig = '{
"Mode": "Install"
}'
public.json
{
"ResourceZipFileUri": "<resource-zip-file-uri>",
"Mode": "Install"
}
powershell format
$publicConfig = '{
"ResourceZipFileUri": "<resource-zip-file-uri>",
"Mode": "Install"
}'
public.json
{
"ResourceName": "<resource-name>",
"Mode": "Remove"
}
powershell format
$publicConfig = '{
"ResourceName": "<resource-name>",
"Mode": "Remove"
}'
- Ubuntu 12.04 LTS, 14.04 LTS
- CentOS 6.5 and higher
- Oracle Linux 6.4 and higher
- openSUSE 13.1 and higher
- SUSE Linux Enterprise Server 11 SP3 and higher
- The status of the extension is reported back to Azure so that user can see the status on Azure Portal
- The operation log of the extension is
/var/log/azure/<extension-name>/<version>/extension.log
file.
- To distribute MOF configurations to the Linux VM with Pull Servers, you need to make sure the cron service is running in the VM.
# 1.0 (2015-09-24)
-Initial version