{"id":11271,"date":"2015-08-06T15:30:45","date_gmt":"2015-08-06T15:30:45","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2015\/08\/06\/azure-dsc-extension-2-2-updates-to-publish-azurevmdscconfiguration-cmdlet-for-asm-arm-in-azure-powershell-sdk-version-0-9-7\/"},"modified":"2019-03-05T08:11:50","modified_gmt":"2019-03-05T16:11:50","slug":"azure-dsc-extension-2-2-updates-to-publish-azurevmdscconfiguration-cmdlet-for-asm-arm-in-azure-powershell-sdk-version-0-9-7","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/azure-dsc-extension-2-2-updates-to-publish-azurevmdscconfiguration-cmdlet-for-asm-arm-in-azure-powershell-sdk-version-0-9-7\/","title":{"rendered":"Azure DSC Extension 2.2 &#038; Updates to Publish-AzureVMDscConfiguration cmdlet for ASM &#038; ARM in Azure PowerShell SDK version 0.9.7"},"content":{"rendered":"<div class=\"markdown-body\">\n<h5>NOTE: For information on OS support, and other features, please refer to our <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2014\/11\/20\/release-history-for-the-azure-dsc-extension.aspx\">release history<\/a>.<\/h5>\n<p>Today we released version 2.2 of the Azure DSC Extension to support new functionality in the Publish-AzureVMDscConfiguration cmdlet. To get the latest changes in the publish cmdlet download Azure Powershell SDK version <a href=\"http:\/\/azure.microsoft.com\/en-us\/downloads\/\">0.9.7<\/a><\/p>\n<p>In Azure Powershell SDK version 0.9.5 we introduced new set of cmdlets for deploying the Azure DSC Extension with Azure Resource Manager <a href=\"https:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/resource-group-overview\/\">(ARM)<\/a>. You can read more on the DSC Extension ARM cmdlets <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2015\/07\/20\/introducing-azure-resource-manager-cmdlets-for-azure-powershell-dsc-extension.aspx\">here<\/a>.<\/p>\n<h5>Changes in Publish-AzureVMDscConfiguration cmdlet<\/h5>\n<p>In the previous <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2015\/07\/20\/introducing-azure-resource-manager-cmdlets-for-azure-powershell-dsc-extension.aspx\">blog<\/a>, we talked about adding the following functionality to the Publish-AzureVMDscConfiguration cmdlet:<\/p>\n<ul>\n<li>A switch parameter to skip packing of dependent modules in the configuration archive.\n<ul>\n<li>Allow configuration data in the configuration archive.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>Allow additional content files or directories in the configuration archive.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>As part of these changes we added some new parameters to the Publish-AzureVMDscConfiguration cmdlet for both ASM and ARM.<\/p>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>ConfigurationDataPath\n\\You can now add a <a href=\"https:\/\/technet.microsoft.com\/en-us\/%5Clibrary\/Dn249925.aspx\">configuration data<\/a> file to the configuration archive using publish cmdlet. Note that the configuration data file provided through Set-AzureVMDscExtension cmdlet takes precedence over the one added through publish cmdlet.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>AdditionalPath\n(&#8220;The Publish cmdlet can now package any additional files or directories in the configuration archive using this parameter. Configurations that require additional content can benefit from this change. For example, while installing the Fourth Coffee website demo (documented below), FourthCoffee.ps1 requires the website&#8217;s content directory. By using the AdditionalPath parameter, that content can be packaged with the publish cmdlet. The additional content is downloaded to the VM along with the configuration.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>SkipDependencyDetection\n&#8220;By default, the publish cmdlet packages dependent resources by parsing the configuration script in the archive it creates. If the resources are already available in the VM, you can use this switch to skip that step and avoid repackaging redundant content.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>PassThru\n(&#8220;Outputs the blob url for the configuration archive path. Note that this parameter is only valid for ASM Publish-AzureVMDscConfiguration cmdlet. For ARM, publish cmdlet outputs the url by default.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Here are some examples on how to use the new parameters in publish cmdlet<\/p>\n<p>For the purpose of this demo we will use the Fourth Coffee configuration and ASM syntax of Publish-AzureVmDscConfiguration cmdlet.<\/p>\n<div class=\"highlight highlight-powershell\">\n<pre class=\"lang:default decode:true\">#FourthCoffee.ps1\r\nConfiguration WebSite { \r\n   Import-DscResource -Module xWebAdministration     \r\n #AllNodes defined in the FourthCoffee.psd1 file (below). This will select the node with property 'Role' as 'TestNode'\r\n    Node $AllNodes.Where{$_.Role -eq 'TestNode'}.NodeName\r\n\r\n        # Install the IIS role  \r\n        WindowsFeature IIS  \r\n        {  \r\n            Ensure          = 'Present'  \r\n            Name            = 'Web-Server'  \r\n        }  \r\n\r\n        # Install the ASP .NET 4.5 role  \r\n        WindowsFeature AspNet45  \r\n        {  \r\n            Ensure          = 'Present'  \r\n            Name            = 'Web-Asp-Net\r\n45'          } \r\n        # Stop the default website  \r\n       xWebsite DefaultSite   \r\n        {  \r\n            Ensure          = 'Present'  \r\n            Name            = 'Default Web Site'  \r\n            State           = 'Stopped'  \r\n            PhysicalPath    = 'C:\\\\inetpub\\\\wwwroot'  \r\n            DependsOn       = '[WindowsFeature]IIS'  \r\n        }  \r\n\r\n       # Copy the website content  \r\n        File WebContent  \r\n       {  \r\n            Ensure          = 'Present'  \r\n            SourcePath      = \\\"$PSScriptRoot\\\\BakeryWebsite\\\r\n            DestinationPath = 'C:\\\\inetpub\\\\FourthCoffee' \r\n            Recurse         = $true  \r\n            Type            = 'Directory'  \r\n            DependsOn       = '[WindowsFeature]AspNet45'  \r\n  }  \r\n       # Create a new website  \r\n       xWebsite BakeryWebSite   \r\n\r\n            Ensure          = 'Present'  \r\n       Name            = 'FourthCoffee' \r\n           State           = 'Started'  \r\n           PhysicalPath    = 'C:\\\\inetpub\\\\FourthCoffee' \r\n           DependsOn       = '[File]WebContent'  \r\n      } \r\n    }\r\n}  \r\n<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<div class=\"highlight highlight-powershell\">\n<pre class=\"lang:default decode:true \">#FourthCoffee.psd1\r\n    AllNodes = @\r\n        @{\r\n            NodeName = \\\"localhost\\\";\r\n            Role     = \\\"TestNode\\\"\r\n        }\\    );\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<\/div>\n<p>Note that in the &#8216;WebContent&#8217; File resource you can now specify source path as <code>$PSScriptRoot\\\\BakeryWebsite<\/code>. We can package &#8216;Bakery Website&#8217; directory as additional content in the configuration archive using the Publish cmdlet. Once we publish Fourth Coffee configuration archive, DSC extension will unpack it and copy the website content to the same directory as the configuration.<\/p>\n<h5>Using ConfigurationDataPath and AdditonalContent parameter without -SkipDependencyDetection switch<\/h5>\n<p>Archive your configuration script, configuration data and any additional content together using publish cmdlet. By default, all DSC resources gets copied over to <code>$env:ProgramFiles\\\\Windows Powershell\\\\Modules<\/code> and configuration data along with any additional content to the configuration directory on the VM.<\/p>\n<pre class=\"lang:default decode:true \">PS C:\\\\&gt; Publish-AzureVMDscConfiguration -ConfigurationPath 'C:\\\\data\\\\dscsolutions\\\\dsc-azure-ext\\\\tests\\\\data\\\\configurations\\\\FourthCoffee.ps1' -ConfigurationArchivePath 'C:\\\\demo\\\\FourthCoffee.ps1.zip' \\-ConfigurationDataPath 'C:\\\\data\\\\dscsolutions\\\\dsc-azure-ext\\\\tests\\\\data\\\\configurations\\\\FourthCoffee.psd1' -AdditionalPath @(\\\"C:\\\\data\\\\dscsolutions\\\\dsc-azure-ext\\\\tests\\\\data\\\\BakeryWebsite\\\") -Force -Verbose\\<\/pre>\n<p>&nbsp;<\/p>\n<p>If you open the ZIP package using the file explorer, you will see it contains dscmetadata.json, FourthCoffee.ps1, FourthCoffee.psd1, xWebAdministration and BakeryWebsite directory.<\/p>\n<p><a href=\"https:\/\/camo.githubusercontent.com\/285bacd5d8225b3f72aded5419d862ddb83312bc\/687474703a2f2f706f7765727368656c6c2e6769746875622e696f2f506f7765725368656c6c2d426c6f672f496d616765732f4453432f436f6e66696775726174696f6e41726368697665576974684d6f64756c65732e706e67\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" style=\"max-width: 100%;\" title=\"Without -SkipDependencyDetection Image\" src=\"https:\/\/camo.githubusercontent.com\/285bacd5d8225b3f72aded5419d862ddb83312bc\/687474703a2f2f706f7765727368656c6c2e6769746875622e696f2f506f7765725368656c6c2d426c6f672f496d616765732f4453432f436f6e66696775726174696f6e41726368697665576974684d6f64756c65732e706e67\" alt=\"alt text\" \/><\/a><\/p>\n<h5>&#8216;Metadata dscmetadata.json&#8217; file and its use<\/h5>\n<p>The file &#8216;dscmetadata.json&#8217; contains information about the configuration data path, DSC resources and other files\/directories as additional content. It is created and copied to the archive based on the input parameters by the publish cmdlet.<\/p>\n<p>Here are the contents of the dscmetadata.json file for the Fourth Coffee configuration:<\/p>\n<div class=\"highlight highlight-powershell\">\n<pre class=\"lang:default decode:true\">{\\\"ConfigurationData\\\":\\\"FourthCoffee.psd1\\\",\\\"AdditionalContent\\\":[\\\"BakeryWebsite\\\"],\\\"Modules\\\":[\\\"xWebAdministration\\\"]}<\/pre>\n<\/div>\n<p>ConfigurationData &#8211; &#8216;FourthCoffee.psd1&#8217; is the configuration data file that was passed to the publish cmdlet. This data file is used by DSC extension unless it is overwritten by a data file through set cmdlet.\nAdditionalContent &#8211; represents a list of files and directories passed to the publish cmdlet through the AdditionalPath parameter. In this example, the Fourth Coffee configuration requires website content to complete successfully, so the metadata file points to the &#8216;BakeryWebsite&#8217; directory as additional content.\nModules &#8211; are DSC resources required by the configuration script. Fourth Coffee requires &#8216;xWebAdministration&#8217; DSC resource to run.<\/p>\n<h5>Using ConfigurationDataPath and Ad\nditionalContent parameter with -SkipDependencyDetection switch<\/h5>\n<p>If you already have DSC resources required by the configuration script on the VM, you can use &#8216;SkipDependencyDetection&#8217; switch to skip adding it in the archive.<\/p>\n<pre class=\"lang:default decode:true \">PS C:\\\\&gt; Publish-AzureVMDscConfiguration -ConfigurationPath 'C:\\\\data\\\\dscsolutions\\\\dsc-azure-ext\\\\tests\\\\data\\\\configurations\\\\FourthCoffee.ps1' -ConfigurationArchivePath 'C:\\\\demo\\\\FourthCoffee.ps1.zip' \\-ConfigurationDataPath 'C:\\\\data\\\\dscsolutions\\\\dsc-azure-ext\\\\tests\\\\data\\\\configurations\\\\FourthCoffee.psd1' -AdditionalPath @(\\\"C:\\\\data\\\\dscsolutions\\\\dsc-azure-ext\\\\tests\\\\data\\\\BakeryWebsite\\\") -SkipDependencyDetection -Force -Verbose\\<\/pre>\n<p>&nbsp;<\/p>\n<p>If you open the ZIP package using the file explorer, you will see it contains dscmetadata.json, FourthCoffee.ps1, FourthCoffee.psd1 and BakeryWebsite directory. The DSC resource module &#8216;xWebAdministration&#8217; does not exist in the archive.<\/p>\n<p><a href=\"https:\/\/camo.githubusercontent.com\/5c29b7df59a13c8acee9dae58d06d3d9b4541b57\/687474703a2f2f706f7765727368656c6c2e6769746875622e696f2f506f7765725368656c6c2d426c6f672f496d616765732f4453432f436f6e66696775726174696f6e41726368697665576974686f75744d6f64756c65732e706e67\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" style=\"max-width: 100%;\" title=\"With -SkipDependencyDetection Image\" src=\"https:\/\/camo.githubusercontent.com\/5c29b7df59a13c8acee9dae58d06d3d9b4541b57\/687474703a2f2f706f7765727368656c6c2e6769746875622e696f2f506f7765725368656c6c2d426c6f672f496d616765732f4453432f436f6e66696775726174696f6e41726368697665576974686f75744d6f64756c65732e706e67\" alt=\"alt text\" \/><\/a><\/p>\n<p>Here are the contents of the dscmetadata.json file with &#8216;SkipDependencyDetection&#8217; switch. Since &#8216;xWebAdministration&#8217; module does not exist in the archive, its entry is also missing from the metadata file.<\/p>\n<div class=\"highlight highlight-powershell\">\n<pre class=\"lang:default decode:true\">{\\\"ConfigurationData\\\":\\\"FourthCoffee.psd1\\\",\\\"AdditionalContent\\\":[\\\"BakeryWebsite\\\"]}<\/pre>\n<\/div>\n<p>If the publish cmdlet is used to upload or create the configuration archive, it will generate and package the metadata file to the archive. However, if you are creating the ZIP file on your own and would like to package configuration data and any other additional files then you need to create a metadata file just like the sample below.<\/p>\n<p>Sample:<\/p>\n<div class=\"highlight highlight-powershell\">\n<pre class=\"lang:default decode:true\">{\\\"ConfigurationData\\\":\\\"ConfigData.psd1\\\",\\\"AdditionalContent\\\":[\\\"Directory1\\\",\\\"File1.txt\\\"],\\\"Modules\\\":[\\\"Module1\\\"]}<\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>NOTE: For information on OS support, and other features, please refer to our release history. Today we released version 2.2 of the Azure DSC Extension to support new functionality in the Publish-AzureVMDscConfiguration cmdlet. To get the latest changes in the publish cmdlet download Azure Powershell SDK version 0.9.7 In Azure Powershell SDK version 0.9.5 we [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-11271","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>NOTE: For information on OS support, and other features, please refer to our release history. Today we released version 2.2 of the Azure DSC Extension to support new functionality in the Publish-AzureVMDscConfiguration cmdlet. To get the latest changes in the publish cmdlet download Azure Powershell SDK version 0.9.7 In Azure Powershell SDK version 0.9.5 we [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/11271","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=11271"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/11271\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=11271"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=11271"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=11271"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}