{"id":1581,"date":"2014-08-07T10:31:00","date_gmt":"2014-08-07T10:31:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2014\/08\/07\/introducing-the-azure-powershell-dsc-desired-state-configuration-extension\/"},"modified":"2024-02-20T13:04:57","modified_gmt":"2024-02-20T21:04:57","slug":"introducing-the-azure-powershell-dsc-desired-state-configuration-extension","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/introducing-the-azure-powershell-dsc-desired-state-configuration-extension\/","title":{"rendered":"Introducing the Azure PowerShell DSC (Desired State Configuration) extension"},"content":{"rendered":"<p><strong>UPDATE 11\/4\/2014: For information on using PSCredential objects, please refer to <strong><span style=\"font-size: 9pt;font-family: 'Arial',sans-serif;color: black;line-height: 107%\"><a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2014\/09\/10\/secure-credentials-in-the-azure-powershell-desired-state-configuration-dsc-extension.aspx\">this blog post<\/a>.<\/span><\/strong><\/strong><\/p>\n<p><strong>UPDATE 11\/21\/2014: For information on OS support, and other features, please refer to our <strong><span style=\"font-size: 9pt;font-family: 'Arial',sans-serif;color: black;line-height: 107%\"><a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2014\/11\/20\/release-history-for-the-azure-dsc-extension.aspx\">release history<\/a><\/span><\/strong>.<\/strong><\/p>\n<p>For the latest information regarding DSC Extension, refer to the product\u00a0<a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/virtual-machines\/windows\/extensions-dsc-overview\">documentation.<\/a><\/p>\n<p>&#8230;&#8230;&#8230;.<\/p>\n<p>Earlier this year Microsoft released the <a href=\"http:\/\/azure.microsoft.com\/blog\/2014\/04\/11\/vm-agent-and-extensions-part-1\/\">Azure VM Agent and Extensions<\/a> as part of the Windows Azure Infrastructure Services. VM Extensions are software components that extend the VM functionality and simplify various VM management operations; for example, the VMAccess extension can be used to reset a VM\u2019s password, or the <a href=\"http:\/\/azure.microsoft.com\/blog\/2014\/04\/24\/automating-vm-customization-tasks-using-custom-script-extension\/\">Custom Script extension<\/a> can be used to execute a script on the VM.<\/p>\n<p>Today, we are introducing the PowerShell Desired State Configuration (DSC) Extension for Azure VMs as part of the <a href=\"http:\/\/azure.microsoft.com\/en-us\/downloads\/\">Azure PowerShell SDK<\/a><strong>.<\/strong> You can use new cmdlets to upload and apply a PowerShell DSC configuration on an Azure VM enabled with the PowerShell DSC extension. PowerShell DSC extension will call into PowerShell DSC to enact the received DSC configuration on the VM.<\/p>\n<p>If you already have the Azure PowerShell SDK installed, you will need to update to version <a href=\"http:\/\/go.microsoft.com\/?linkid=9811175&amp;clcid=0x409\"><strong>0.8.6<\/strong><\/a> or later.<\/p>\n<p>Once you <a href=\"http:\/\/azure.microsoft.com\/en-us\/documentation\/articles\/install-configure-powershell\/\">have installed and configured Azure PowerShell and authenticated to Azure<\/a>, you can use the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/azure\/dn606311.aspx#bk_find\">Get-AzureVMAvailableExtension<\/a> cmdlet to see the PowerShell DSC extension.<\/p>\n<pre style=\"color: #eeedf0;background-color: #012456\">PS C:\\&gt; <span style=\"color: #ff0;background-color: #012456\">Get-AzureVMAvailableExtension<\/span> <span style=\"color: #888;background-color: #012456\">-Publisher<\/span> Microsoft.PowerShell                                                   \r\n                                                                                                                        \r\nPublisher                  : Microsoft.Powershell                                                                       \r\nExtensionName              : DSC                                                                                        \r\nVersion                    : 1.0                                                                                        \r\nPublicConfigurationSchema  :                                                                                            \r\nPrivateConfigurationSchema :                                                                                            \r\nSampleConfig               :                                                                                            \r\nReplicationCompleted       : True                                                                                       \r\nEula                       : http:\/\/azure.microsoft.com\/en-us\/support\/legal\/                                            \r\nPrivacyUri                 : http:\/\/www.microsoft.com\/                                                                  \r\nHomepageUri                : http:\/\/blogs.msdn.com\/b\/powershell\/                                                        \r\nIsJsonExtension            : True                                                                                       \r\n<\/pre>\n<h4>Executing a simple scenario<\/h4>\n<p>One scenario in which this new extension can be used is the automation of software installation and configuration upon a machine\u2019s initial boot-up.<\/p>\n<p>As a simple example, let\u2019s say you need to create a new VM and install IIS on it. For this, you would first create a PowerShell script that defines the configuration (NOTE: I saved this script as C:\\examples\\IISInstall.ps1):<\/p>\n<div style=\"overflow: auto;font-size: 10pt;font-family: consolas,lucida console;width: 650px;border: black 1px solid;padding: 5px\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #cecece;padding: 5px\">001\n002\n003\n004\n005\n006\n007\n008\n009\n010\n011\n012<\/div>\n<\/td>\n<td valign=\"top\" nowrap=\"nowrap\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #fcfcfc;padding: 5px\"><span style=\"color: #00008b\">configuration<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">IISInstall<\/span>\n<span style=\"color: #000000\">{<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">node<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #8b0000\">&#8220;localhost&#8221;<\/span><span style=\"color: #000000\">)<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">WindowsFeature<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">IIS<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Web-Server&#8221;<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span>\n<span style=\"color: #000000\">}<\/span><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Then you would use Publish-AzureVMDscConfiguration to upload your configuration to Azure storage. Publish-AzureVMDscConfiguration is one of the new cmdlets in the Azure PowerShell SDK. The example below uses all the default values, but later in this post we\u2019ll go over more details of how this <a>works<\/a>.<\/p>\n<pre style=\"color: #eeedf0;background-color: #012456\">PS C:\\&gt; <span style=\"color: #ff0;background-color: #012456\">Publish-AzureVMDscConfiguration<\/span> <span style=\"color: #888;background-color: #012456\">-ConfigurationPath<\/span> C:\\examples\\IISInstall.ps1                                   \r\n<\/pre>\n<p>This cmdlet creates a ZIP package that follows a predefined format that the PowerShell Desired State Configuration Extension can understand and then uploads it as a blob to Azure storage. The ZIP package in the above example was uploaded to<\/p>\n<p align=\"center\">https:\/\/examples.blob.core.windows.net\/windows-powershell-dsc\/IISInstall.ps1.zip<\/p>\n<p>\u201cexamples\u201d in this URI is the name of my default Azure storage account, \u201cwindows-powershell-dsc\u201d is the default storage container used by the cmdlet, and \u201cIISInstall.ps1.zip\u201d is the name of the blob for the file I just published.<\/p>\n<p>Now my sample configuration is available for VMs to use, so let\u2019s write a script that creates a VM that uses our sample configuration (NOTE: I saved this script as C:\\examples\\example-1.ps1):<\/p>\n<div style=\"overflow: auto;font-size: 10pt;font-family: consolas,lucida console;width: 650px;border: black 1px solid;padding: 5px\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #cecece;padding: 5px\">001\n002\n003\n004\n005\n006\n007\n008<\/div>\n<\/td>\n<td valign=\"top\" nowrap=\"nowrap\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #fcfcfc;padding: 5px\">\n<p><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">New-AzureVMConfig<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-Name<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;example-1&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-InstanceSize<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">Small<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-ImageName<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201407.01-en.us-127GB.vhd&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><\/p>\n<p><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Add-AzureProvisioningConfig<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-VM<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-Windows<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-AdminUsername<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;admin_account&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-Password<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Bull_dog1&#8221;<\/span><\/p>\n<p><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Set-AzureVMDSCExtension<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-VM<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-ConfigurationArchive<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;IISInstall.ps1.zip&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-ConfigurationName<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;IISInstall&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><\/p>\n<p><span style=\"color: #0000ff\">New-AzureVM<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-VM<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-Location<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;West US&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-ServiceName<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;example-1-svc&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-WaitForBoot<\/span><\/p>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>New-AzureVMConfig, Add-AzureProvisioningConfig, and New-AzureVM are the existing Azure cmdlets used to create a VM. The new kid on the block is Set-AzureVMDscExtension\u00a0\u00a0(line 5 of above example).<\/p>\n<p>This cmdlet injects a DSC configuration into the VM configuration object ($vm in the example). When the VM machine boots, the Azure VM agent will install the PowerShell DSC Extension, which in turn will download the ZIP package that we published previously (IISInstall.ps1.zip), will execute the \u201cIISInstall\u201d configuration that we included as part of IISInstall.ps1, and then will invoke PowerShell DSC by calling the Start-DscConfiguration cmdlet.<\/p>\n<p>Now, let\u2019s go ahead and execute the sample script (NOTE: if you get an error telling you that the VM vhd is not available or you don\u2019t have access to it, that likely means that the image referenced on line 1 of the script has been updated, and you will need to find the new image name. You can do so by enumerating the available images with Get-AzureVMImage and picking the image that you wish to use. See Azure SDK documentation for more details on this. In my case, I will use a 2012-R2 machine).<\/p>\n<pre style=\"color: #eeedf0;background-color: #012456\">PS C:\\&gt; <span style=\"color: #ff0;background-color: #012456\">C:\\examples\\example-1.ps1<\/span>                                                                                       \r\n                                                                                                                        \r\nOperationDescription          OperationId                             OperationStatus                         \r\n--------------------          -----------                             ---------------                         \r\nNew-AzureVM                   9cfb922d-db5b-cdd0-9c74-1a4e34b91e28    Succeeded                               \r\nNew-AzureVM                   17acca22-c6ff-cb5a-8116-a41ff9764d35    Succeeded                               \r\n                                                                                                                        \r\n<\/pre>\n<p>Our sample configuration was very simple: it just installed IIS. As a quick verification that it executed properly, we can logon to the VM and verify that IIS is installed by visiting the default web site (<a href=\"http:\/\/localhost\">http:\/\/localhost<\/a>):<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/30\/2018\/10\/5822.iis_thumb_249B9C00.png\"><img decoding=\"async\" style=\"float: none;margin-left: auto;margin-right: auto;border-width: 0px\" title=\"iis\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/30\/2018\/10\/5822.iis_thumb_249B9C00.png\" alt=\"iis\" width=\"603\" height=\"500\" border=\"0\" \/><\/a><\/p>\n<p>That is the PowerShell DSC Extension in a nutshell.<\/p>\n<p>And now for the gory details\u2026<\/p>\n<h4><\/h4>\n<h4><\/h4>\n<h4>Publish-AzureVMDscConfiguration<\/h4>\n<p>As the previous example illustrated, the first step in using the PowerShell Desired State Configuration Extension is <em>publishing<strong>. <\/strong><\/em>In this context, publishing is the process of creating a ZIP package that the extension can understand and uploading that package to Azure blob storage. This is accomplished using the Publish-AzureVMDscConfiguration cmdlet.<\/p>\n<p>Why use a ZIP package for publishing? Publish-AzureVMDscConfiguration will parse your configuration looking for Import-DSCResource statements and will include a copy of the corresponding modules along with the script that contains your configuration. For example, let\u2019s take a look at the ZIP package produced by a configuration that creates an actual website instead of just installing IIS. This new example is the FourthCoffee website, which you may have already seen in other DSC blog posts or demos). The FourthCoffee demo has a dependency on the DSC resource xWebAdministration, which is included in the <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2014\/07\/17\/powershell-dsc-resource-kit-wave-5-arrives.aspx\">DSC Resource Kit Wave 5<\/a>.<\/p>\n<p>(NOTE: I saved this script as C:\\examples\\FourthCoffee.ps1)<\/p>\n<div style=\"overflow: auto;font-size: 10pt;font-family: consolas,lucida console;width: 650px;border: black 1px solid;padding: 5px\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #cecece;padding: 5px\">001\n002\n003\n004\n005\n006\n007\n008\n009\n010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n020\n021\n022\n023\n024\n025\n026\n027\n028\n029\n030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n040\n041\n042\n043\n044\n045\n046\n047\n048\n049<\/div>\n<\/td>\n<td valign=\"top\" nowrap=\"nowrap\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #fcfcfc;padding: 5px\">\n<p><span style=\"color: #00008b\">configuration<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">FourthCoffee<\/span>\n<span style=\"color: #000000\">{<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #0000ff\">Import-DscResource<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-Module<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">xWebAdministration<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/p>\n<p><span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Install the IIS role <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">WindowsFeature<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">IIS<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Web-Server&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Install the ASP .NET 4.5 role <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">WindowsFeature<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">AspNet45<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Web-Asp-Net45&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Stop the default website <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">xWebsite<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">DefaultSite<\/span><span style=\"color: #000000\">\u00a0 <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Default Web Site&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">State<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Stopped&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">PhysicalPath<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;C:\\inetpub\\wwwroot&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">DependsOn<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;[WindowsFeature]IIS&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Copy the website content <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">File<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">WebContent<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">SourcePath<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;C:\\Program Files\\WindowsPowerShell\\Modules\\xWebAdministration\\BakeryWebsite&#8221;<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">DestinationPath<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;C:\\inetpub\\FourthCoffee&#8221;<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Recurse<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$true<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Type<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Directory&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">DependsOn<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;[WindowsFeature]AspNet45&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0 <\/span><\/p>\n<p><span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Create a new website <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">xWebsite<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">BakeryWebSite<\/span><span style=\"color: #000000\">\u00a0 <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;FourthCoffee&#8221;<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">State<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Started&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">PhysicalPath<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;C:\\inetpub\\FourthCoffee&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">DependsOn<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;[File]WebContent&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">}<\/span><\/p>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>To inspect the ZIP package created by the publish cmdlet I used the -ConfigurationArchivePath parameter, which saves the package to a local file instead of uploading it to Azure storage (NOTE: I typed the command below in two separate lines using the &#96; character; the &gt;&gt;&gt; characters are PowerShell\u2019s prompt):<\/p>\n<pre style=\"color: #eeedf0;background-color: #012456\">PS C:\\&gt; <span style=\"color: #ff0;background-color: #012456\">Publish-AzureVMDscConfiguration<\/span> C:\\examples\\FourthCoffee.ps1 `                                                  \r\n&gt;&gt;&gt; <span style=\"color: #888;background-color: #012456\">-ConfigurationArchivePath<\/span> C:\\examples\\FourthCoffee.ps1.zip<\/pre>\n<p>When I look at the ZIP package using the File Explorer I can see that it contains my configuration script and a copy of the xWebAdministration module:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/30\/2018\/10\/5736.FourthCoffee.ps1.zip_1D7C5F88.png\"><img decoding=\"async\" style=\"float: none;margin-left: auto;margin-right: auto;border-width: 0px\" title=\"FourthCoffee.ps1.zip\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/30\/2018\/10\/5736.FourthCoffee.ps1.zip_1D7C5F88.png\" alt=\"FourthCoffee.ps1.zip\" width=\"675\" height=\"205\" border=\"0\" \/><\/a><\/p>\n<p>That copy comes from the xWebAdministration module that I already installed on my machine under \u201cC:\\Program Files\\WindowsPowerShell\\Modules\u201d. The publish cmdlet requires that the imported modules are installed on your machine, and that they are located somewhere in $PSModulePath.<\/p>\n<p>(NOTE: To simplify the example, I slightly altered the xWebAdministration module so it included the files needed for the website as part of the xWebAdministration module, in the \u201cBakeryWebsite\u201d directory)<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/30\/2018\/10\/0574.xWebAdministration_3B5D743A.png\"><img decoding=\"async\" style=\"float: none;margin-left: auto;margin-right: auto;border-width: 0px\" title=\"xWebAdministration\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/30\/2018\/10\/0574.xWebAdministration_3B5D743A.png\" alt=\"xWebAdministration\" width=\"679\" height=\"198\" border=\"0\" \/><\/a><\/p>\n<p>The two previous examples use a PowerShell Script file (.ps1) to define the configuration that will be published. You can also do this in a PowerShell Module file (.psm1), or if the configuration you want to publish is part of a larger module, you can create the ZIP package manually and simply copy the directories for the module that defines your configuration and any modules referenced by your configuration. For example, if the configuration of our example was defined within a PowerShell module named FourthCoffee the ZIP package would include these two directories: the FourthCoffee module folder, and the dependent DSC resource module folder for xWebAdministration<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2014\/08\/6864.FourthCoffee.zip_thumb_71CE263C.png\"><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2014\/08\/6864.FourthCoffee.zip_thumb_71CE263C.png\" alt=\"fourth coffee zip\" width=\"694\" height=\"214\" class=\"aligncenter size-full wp-image-14532\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2014\/08\/6864.FourthCoffee.zip_thumb_71CE263C.png 694w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2014\/08\/6864.FourthCoffee.zip_thumb_71CE263C-300x93.png 300w\" sizes=\"(max-width: 694px) 100vw, 694px\" \/><\/a><\/p>\n<p>Once you have a local ZIP package (either created manually, or using the publish cmdlet), you can upload it to Azure storage with the publish cmdlet:<\/p>\n<pre style=\"color: #eeedf0;background-color: #012456\">PS C:\\&gt; <span style=\"color: #ff0;background-color: #012456\">Publish-AzureVMDscConfiguration<\/span> C:\\examples\\FourthCoffee.ps1.zip<\/pre>\n<h5>ContainerName and StorageContext parameters<\/h5>\n<p>By default Publish-AzureVMDscConfiguration will upload the ZIP package to Azure blob storage using \u201cwindows-powershell-dsc\u201d as the container and picking up the default storage account from the settings of your Azure subscription.<\/p>\n<p>You can change the container using the \u2013ContainerName parameter:<\/p>\n<pre style=\"color: #eeedf0;background-color: #012456\">PS C:\\&gt; <span style=\"color: #ff0;background-color: #012456\">Publish-AzureVMDscConfiguration<\/span> C:\\examples\\FourthCoffee.ps1.zip `                                              \r\n&gt;&gt;&gt; <span style=\"color: #888;background-color: #012456\">-ContainerName<\/span> mycontainer<\/pre>\n<p>And you can change the storage account (and authentication settings) using the \u2013StorageContext parameter (you can use the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/dn495246.aspx\">New-AzureStorageContext<\/a> cmdlet to create the storage context).<\/p>\n<h4>Set-AzureVMDSCExtension<\/h4>\n<p>Once a configuration has been published, you can apply it to any Azure virtual machine using the Set-AzureVMDSCExtension cmdlet. This cmdlet injects the settings needed by the PowerShell DSC extension into a VM configuration object, which can then be applied to a new VM, as in our first example, or to an existing VM. Let\u2019s use this cmdlet again to update the VM we created previously (NOTE: the first example used the configuration defined in C:\\examples\\IISInstall.ps1; now we will update this machine with the configuration defined in C:\\examples\\FourthCoffee.ps1; the script that we will use was saved as C:\\examples\\example-2.ps1. Also note that this example uses Update-AzureVM instead of New-AzureVM because we are applying the extension to a VM that already exists.)<\/p>\n<div style=\"overflow: auto;font-size: 10pt;font-family: consolas,lucida console;width: 650px;border: black 1px solid;padding: 5px\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #cecece;padding: 5px\">001\n002\n003\n004\n005\n006<\/div>\n<\/td>\n<td valign=\"top\" nowrap=\"nowrap\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #fcfcfc;padding: 5px\">\n<p><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Get-AzureVM<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-Name<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;example-1&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-ServiceName<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;example-1-svc&#8221;<\/span><\/p>\n<p><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Set-AzureVMDSCExtension<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-VM<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-ConfigurationArchive<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;FourthCoffee.ps1.zip&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-ConfigurationName<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;FourthCoffee&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><\/p>\n<p><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">|<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Update-AzureVM<\/span><\/p>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<pre style=\"color: #eeedf0;background-color: #012456\">PS C:\\&gt; <span style=\"color: #ff0;background-color: #012456\">C:\\examples\\example-2.ps1<\/span>                                                                                       \r\n                                                                                                                        \r\nOperationDescription              OperationId                             OperationStatus                         \r\n--------------------              -----------                             ---------------                         \r\nUpdate-AzureVM                    afa38e1a-5717-cac6-a6e7-6f72d0af51d2    Succeeded<\/pre>\n<p>In our first example we were working with a new VM, so the Azure VM agent first installed the PowerShell DSC Extension and then it invoked it using the information provided by the Set-AzureVMDSCExtension cmdlet. In this second example we are working on an existing VM on which the extension is already installed so the Azure VM agent will skip the installation part and just invoke the PowerShell DSC Extension with the new information provided by the set cmdlet.<\/p>\n<p>The extension will then<\/p>\n<ul>\n<li>download the ZIP package specified by the \u2013ConfigurationArchive parameter and expand it to a temporary directory<\/li>\n<li>remove the .zip extension from the value given by \u2013ConfigurationArchive and look for a PowerShell script or module with that name and execute it (in our second example, it will look for FourthCoffee.ps1)<\/li>\n<li>look for and execute the configuration named by the -ConfigurationName parameter (in this case &#8220;WebSite&#8221;)<\/li>\n<li>invoke the Start-DscConfiguration with the output produced by that configuration<\/li>\n<\/ul>\n<p>To verify that our second configuration was applied successfully we can again check the default website:<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2014\/08\/6403.FourthCoffeeWebsite_thumb_2D218BFB.png\"><img decoding=\"async\" src=\"http:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2014\/08\/6403.FourthCoffeeWebsite_thumb_2D218BFB.png\" alt=\"cupcakes 5.99\" width=\"630\" height=\"543\" class=\"aligncenter size-full wp-image-14533\" srcset=\"https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2014\/08\/6403.FourthCoffeeWebsite_thumb_2D218BFB.png 630w, https:\/\/devblogs.microsoft.com\/powershell\/wp-content\/uploads\/sites\/30\/2014\/08\/6403.FourthCoffeeWebsite_thumb_2D218BFB-300x259.png 300w\" sizes=\"(max-width: 630px) 100vw, 630px\" \/><\/a><\/p>\n<h5>Configuration Arguments<\/h5>\n<p>DSC configurations are very similar to PowerShell advanced functions and can be parameterized for greater flexibility. The PowerShell DSC extension provides support for configuration arguments via the \u2013ConfigurationArgument parameter of Set-AzureVMDSCExtension.<\/p>\n<p>As a very simple example, let\u2019s change our last script in such a way that the name of the website is a parameter to the FourthCoffee configuration. The updated configuration has been saved as C:\\examples\\FourthCoffeeWithArguments.ps1; notice that we have added the $WebSiteName parameter (lines 4-7), which is used as the Name property of the BakeryWebSite resource (line 51).<\/p>\n<div style=\"overflow: auto;font-size: 10pt;font-family: consolas,lucida console;width: 650px;border: black 1px solid;padding: 5px\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #cecece;padding: 5px\">001\n002\n003\n004\n005\n006\n007\n008\n009\n010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n020\n021\n022\n023\n024\n025\n026\n027\n028\n029\n030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n040\n041\n042\n043\n044\n045\n046\n047\n048\n049\n050\n051\n052\n053\n054\n055\n056<\/div>\n<\/td>\n<td valign=\"top\" nowrap=\"nowrap\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #fcfcfc;padding: 5px\">\n<p><span style=\"color: #00008b\">configuration<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">FourthCoffee<\/span>\n<span style=\"color: #000000\">{<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">[<\/span><span style=\"color: #00bfff\">CmdletBinding<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #a9a9a9\">]<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #00008b\">param<\/span><span style=\"color: #000000\">(<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">[<\/span><span style=\"color: #00bfff\">Parameter<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #000000\">Mandatory<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #ff4500\">$true<\/span><span style=\"color: #a9a9a9\">,<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000000\">Position<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #800080\">0<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #a9a9a9\">]<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #008080\">[string]<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #ff4500\">$WebSiteName<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">)<\/span><\/p>\n<p><span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #0000ff\">Import-DscResource<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-Module<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">xWebAdministration<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/p>\n<p><span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Install the IIS role <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">WindowsFeature<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">IIS<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Web-Server&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Install the ASP .NET 4.5 role <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">WindowsFeature<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">AspNet45<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Web-Asp-Net45&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Stop the default website <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">xWebsite<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">DefaultSite<\/span><span style=\"color: #000000\">\u00a0 <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Default Web Site&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">State<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Stopped&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">PhysicalPath<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;C:\\inetpub\\wwwroot&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">DependsOn<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;[WindowsFeature]IIS&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Copy the website content <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">File<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">WebContent<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">SourcePath<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;C:\\Program Files\\WindowsPowerShell\\Modules\\xWebAdministration\\BakeryWebsite&#8221;<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">DestinationPath<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;C:\\inetpub\\FourthCoffee&#8221;<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Recurse<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$true<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Type<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Directory&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">DependsOn<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;[WindowsFeature]AspNet45&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0 <\/span><\/p>\n<p><span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Create a new website <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">xWebsite<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">BakeryWebSite<\/span><span style=\"color: #000000\">\u00a0 <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$WebSiteName<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">State<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Started&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">PhysicalPath<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;C:\\inetpub\\FourthCoffee&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">DependsOn<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;[File]WebContent&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">}<\/span><\/p>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>Our third example publishes the new configuration script and updates the VM that we created previously (I saved this script as C:\\examples\\example-3.ps1:<\/p>\n<div style=\"overflow: auto;font-size: 10pt;font-family: consolas,lucida console;width: 650px;border: black 1px solid;padding: 5px\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #cecece;padding: 5px\">001\n002\n003\n004\n005\n006\n007\n008\n009\n010\n011<\/div>\n<\/td>\n<td valign=\"top\" nowrap=\"nowrap\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #fcfcfc;padding: 5px\">\n<p><span style=\"color: #0000ff\">Publish-AzureVMDscConfiguration<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">C:\\examples\\FourthCoffeeWithArguments.ps1<\/span><\/p>\n<p><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Get-AzureVM<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-Name<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;example-1&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-ServiceName<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;example-1-svc&#8221;<\/span><\/p>\n<p><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Set-AzureVMDscExtension<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-VM<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span>`\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000080\">-ConfigurationArchive<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;FourthCoffeeWithArguments.ps1.zip&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>`\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000080\">-ConfigurationName<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;FourthCoffee&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>`\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000080\">-ConfigurationArgument<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000000\">@{<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000000\">WebSiteName<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;FourthCoffee&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000000\">}<\/span><\/p>\n<p><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">|<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Update-AzureVM<\/span><\/p>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<pre style=\"color: #eeedf0;background-color: #012456\">PS C:\\&gt; <span style=\"color: #ff0;background-color: #012456\">C:\\examples\\example-3.ps1<\/span>                                                                                       \r\n                                                                                                                        \r\nOperationDescription              OperationId                             OperationStatus                         \r\n--------------------              -----------                             ---------------                         \r\nUpdate-AzureVM                    2b6f18e7-42f2-c216-8199-edfa06b52e33    Succeeded                               \r\n<\/pre>\n<p>The value of the \u2013ConfigurationArgument parameter on line 8 of C:\\examples\\example-3.ps1 is a hashtable that specifies the arguments to the WebSite configuration, i.e. a string specifying the name of the website (this corresponds to parameter $WebSiteName, on line 7 of C:\\examples\\FourthCoffeeWithArguments.ps1)<\/p>\n<h5>Configuration Data<\/h5>\n<p>Configuration data can be used to separate <em>structural<\/em> configuration from <em>environmental<\/em> configuration (see <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2014\/01\/09\/continuous-deployment-using-dsc-with-minimal-change.aspx\">this blog post<\/a> for an introduction to those concepts). The PowerShell DSC extension provides support for configuration data via the \u2013ConfigurationDataPath parameters of Set-AzureVMDSCExtension.<\/p>\n<p>Let\u2019s create another variation of the FourthCoffee configuration: IIS and ASP.NET will always be installed by the configuration, but the FourthCoffee website will be installed only if the role of the VM is \u201cWebServer\u201d. The updated configuration has been saved as C:\\examples\\FourthCoffeeWithData.ps1; the check for the VM\u2019s role is on line 20:<\/p>\n<div style=\"overflow: auto;font-size: 10pt;font-family: consolas,lucida console;width: 650px;border: black 1px solid;padding: 5px\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #cecece;padding: 5px\">001\n002\n003\n004\n005\n006\n007\n008\n009\n010\n011\n012\n013\n014\n015\n016\n017\n018\n019\n020\n021\n022\n023\n024\n025\n026\n027\n028\n029\n030\n031\n032\n033\n034\n035\n036\n037\n038\n039\n040\n041\n042\n043\n044\n045\n046\n047\n048\n049\n050\n051\n052\n053<\/div>\n<\/td>\n<td valign=\"top\" nowrap=\"nowrap\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #fcfcfc;padding: 5px\">\n<p><span style=\"color: #00008b\">configuration<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">FourthCoffee<\/span>\n<span style=\"color: #000000\">{<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #0000ff\">Import-DscResource<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-Module<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">xWebAdministration<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><\/p>\n<p><span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Install the IIS role <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">WindowsFeature<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">IIS<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Web-Server&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Install the ASP .NET 4.5 role <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">WindowsFeature<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">AspNet45<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Web-Asp-Net45&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Setup the website only if the role is &#8220;WebServer&#8221;<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Node<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$AllNodes<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">Where<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #ff4500\">$_<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">Role<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">-eq<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;WebServer&#8221;<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">NodeName<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Stop the default website <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">xWebsite<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">DefaultSite<\/span><span style=\"color: #000000\">\u00a0 <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Default Web Site&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">State<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Stopped&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">PhysicalPath<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;C:\\inetpub\\wwwroot&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">DependsOn<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;[WindowsFeature]IIS&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Copy the website content <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">File<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">WebContent<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">SourcePath<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;C:\\Program Files\\WindowsPowerShell\\Modules\\xWebAdministration\\BakeryWebsite&#8221;<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">DestinationPath<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;C:\\inetpub\\FourthCoffee&#8221;<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Recurse<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$true<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Type<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Directory&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">DependsOn<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;[WindowsFeature]AspNet45&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0 <\/span><\/p>\n<p><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #006400\"># Create a new website <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">xWebsite<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">BakeryWebSite<\/span><span style=\"color: #000000\">\u00a0 <\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Ensure<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Present&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Name<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$WebSiteName<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">State<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;Started&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">PhysicalPath<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;C:\\inetpub\\FourthCoffee&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">DependsOn<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;[File]WebContent&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span>\n<span style=\"color: #000000\">}<\/span><\/p>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>The configuration data has been saved as C:\\examples\\FourthCoffeeData.psd1:<\/p>\n<div style=\"overflow: auto;font-size: 10pt;font-family: consolas,lucida console;width: 650px;border: black 1px solid;padding: 5px\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #cecece;padding: 5px\">001\n002\n003\n004\n005\n006\n007\n008\n009<\/div>\n<\/td>\n<td valign=\"top\" nowrap=\"nowrap\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #fcfcfc;padding: 5px\"><span style=\"color: #000000\">@{<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">AllNodes<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000000\">@(<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">@{<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">NodeName<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;localhost&#8221;<\/span><span style=\"color: #000000\">;<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">Role<\/span><span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;WebServer&#8221;<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">}<\/span>\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #000000\">;<\/span>\n<span style=\"color: #000000\">}<\/span><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>And the script that publishes and applies this new configuration is C:\\examples\\example-4.ps1:<\/p>\n<div style=\"overflow: auto;font-size: 10pt;font-family: consolas,lucida console;width: 650px;border: black 1px solid;padding: 5px\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #cecece;padding: 5px\">001\n002\n003\n004\n005\n006\n007\n008\n009\n010\n011<\/div>\n<\/td>\n<td valign=\"top\" nowrap=\"nowrap\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #fcfcfc;padding: 5px\">\n<p><span style=\"color: #0000ff\">Publish-AzureVMDscConfiguration<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">C:\\examples\\FourthCoffeeWithData.ps1<\/span><\/p>\n<p><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Get-AzureVM<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-Name<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;example-1&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-ServiceName<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;example-1-svc&#8221;<\/span><\/p>\n<p><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Set-AzureVMDscExtension<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-VM<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span>`\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000080\">-ConfigurationArchive<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;FourthCoffeeWithData.ps1.zip&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>`\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000080\">-ConfigurationName<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;FourthCoffee&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span>`\n<span style=\"color: #000000\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 <\/span><span style=\"color: #000080\">-ConfigurationDataPath<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8a2be2\">C:\\examples\\FourthCoffeeData.psd1<\/span><\/p>\n<p><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">|<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Update-AzureVM<\/span><\/p>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<pre style=\"color: #eeedf0;background-color: #012456\">C:\\ PS&gt; <span style=\"color: #ff0;background-color: #012456\">C:\\examples\\example-4.ps1<\/span>                                                                                       \r\n                                                                                                                        \r\nOperationDescription              OperationId                             OperationStatus                         \r\n--------------------              -----------                             ---------------                         \r\nUpdate-AzureVM                    fa6a525b-c411-c213-8f57-69dc2a09df1c    Succeeded                               \r\n                                                                                                                        \r\n<\/pre>\n<p>The value of\u00a0 the \u2013ConfigurationDataPath parameter on line 8 of C:\\examples\\example-4.ps1 is the path to a local .psd1 file containing the configuration data. A copy of this file will be uploaded to Azure blob storage and then downloaded to the VM by the PowerShell DSC Extension and passed along to the FourthCoffee configuration. This file is uploaded to the default container (\u201cwindows-powershell-dsc\u201d) and storage account; similarly to the Publish-AzureVmDscConfiguration cmdlet, the Set-AzureVMDscExtension cmdlet includes parameters \u2013ContainerName and \u2013StorageContext that can be used to override those defaults.<\/p>\n<h5>ACQUIRING REMOTE ACCESS TO OUR VM<\/h5>\n<p>Since we know the name of your VM we can simply use Azure SDK cmdlets to get RDP file and kick off a remote access to it. See Azure Powershell SDK documentation for more information.<\/p>\n<div style=\"overflow: auto;font-size: 10pt;font-family: consolas,lucida console;width: 650px;border: black 1px solid;padding: 5px\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"5\">\n<tbody>\n<tr>\n<td valign=\"top\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #cecece;padding: 5px\">001\n002\n003\n004\n005\n006<\/div>\n<\/td>\n<td valign=\"top\" nowrap=\"nowrap\">\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #fcfcfc;padding: 5px\"><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Get-AzureVM<\/span><span style=\"color: #000000\"> \u2013<\/span><span style=\"color: #000080\">ServiceName <\/span><span style=\"color: #000080\">&#8220;example-1-svc<\/span><span style=\"color: #000080\">&#8221; \u2013<\/span><span style=\"color: #000080\">Name <\/span><span style=\"color: #000080\">&#8220;<\/span><span style=\"color: #8b0000\">example-1<\/span><span style=\"color: #000080\">&#8220;<\/span><\/div>\n<div style=\"font-size: 10pt;font-family: consolas,lucida console;background: #fcfcfc;padding: 5px\"><span style=\"color: #ff4500\">$rdp<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #0000ff\">Get-AzureEndpoint<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-Name<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;RDP&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-VM<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #ff4500\">$hostdns<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000ff\">New-Object<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;System.Uri&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$vm<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">DNSName<\/span><span style=\"color: #000000\">)<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">Authority<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #ff4500\">$port<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #a9a9a9\">=<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #ff4500\">$rdp<\/span><span style=\"color: #a9a9a9\">.<\/span><span style=\"color: #000000\">Port<\/span><span style=\"color: #000000\">\u00a0<\/span>\n<span style=\"color: #0000ff\">Start-Process<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;mstsc&#8221;<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #000080\">-ArgumentList<\/span><span style=\"color: #000000\">\u00a0<\/span><span style=\"color: #8b0000\">&#8220;\/V:$hostdns`:$port \/w:1024 \/h:768&#8221;<\/span><span style=\"color: #000000\">\u00a0 <\/span><\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h5><\/h5>\n<h5>READING LOGS<\/h5>\n<p>Let us say that I wish to check in detail that everything went well on my VM. How would I do that? I can log in to my VM from Azure and check the local logs. The files of interest to us will be the following two locations on VM hard drive:<\/p>\n<p align=\"center\">C:\\Packages\\Plugins\\Microsoft.Powershell.DSC\\1.0.0.0<\/p>\n<p align=\"center\">C:\\WindowsAzure\\Logs\\Plugins\\Microsoft.Powershell.DSC\\1.0.0.0<\/p>\n<p>You may find that your VM has a newer version of Powershell DSC extension,in which case the version number at the end of the path might be slightly different.<\/p>\n<p>\u201cC:\\Packages\\Plugins\\Microsoft.Powershell.DSC\\1.0.0.0\u201d contains the actual extension files. You generally don\u2019t need to worry about this location. However, if an extension failed to install for some reason and this folder isn\u2019t present, that is a critical issue.<\/p>\n<p>Now let\u2019s start digging into the logs: C:\\WindowsAzure\\Logs. This folder contains general Azure logs that were captured for us. If for some reason DSC extension failed to deploy or there was some general infrastructure error, it would appear here under log files \u201cWaAppAgent.*.log\u201d<\/p>\n<p>The lines of interest in these files are as follows. Note that your log may look slightly different.<\/p>\n<ul>\n<li>[00000003] [07\/28\/2014 23:57:33.02] [INFO]\u00a0 Beginning installation of plugin Microsoft.Powershell.DSC.<\/li>\n<li>[00000003] [07\/28\/2014 23:59:47.25] [INFO]\u00a0 Successfully installed plugin Microsoft.Powershell.DSC.<\/li>\n<li>[00000009] [07\/29\/2014 00:02:51.02] [INFO]\u00a0 Successfully enabled plugin Microsoft.Powershell.DSC.<\/li>\n<li>[00000009] [07\/29\/2014 00:02:51.03] [INFO]\u00a0 Setting the install state of the handler Microsoft.Powershell.DSC_1.0.0.0 to Enabled<\/li>\n<\/ul>\n<p>Now we know that DSC extension was successfully installed and enabled. We continue our analysis by going to DSC extension logs. \u201cC:\\WindowsAzure\\Logs\\Plugins\\Microsoft.Powershell.DSC\\1.0.0.0\u201d contains various logs from DSC extension itself.<\/p>\n<pre style=\"color: #eeedf0;background-color: #012456\">PS C:\\<span style=\"color: #f00;background-color: #012456\">&gt;<\/span> <span style=\"color: #ff0;background-color: #012456\">PS<\/span> C:\\WindowsAzure\\Logs\\Plugins\\Microsoft.Powershell.DSC\\1.0.0.0&gt; dir                                           \r\n                                                                                                                     \r\n    <span style=\"color: #ff0;background-color: #012456\">Directory:<\/span> C:\\WindowsAzure\\Logs\\Plugins\\Microsoft.Powershell.DSC\\1.0.0.0                                        \r\n                                                                                                                    \r\n <span style=\"color: #ff0;background-color: #012456\">Mode<\/span>                LastWriteTime     Length Name                                                                   \r\n<span style=\"color: #888;background-color: #012456\"> ----<\/span>                <span style=\"color: #888;background-color: #012456\">-------------<\/span>     <span style=\"color: #888;background-color: #012456\">------<\/span> <span style=\"color: #888;background-color: #012456\">----<\/span>                                                                   \r\n <span style=\"color: #888;background-color: #012456\">-a---<\/span>         <span style=\"color: #fff;background-color: #012456\">7<\/span><span style=\"color: #888;background-color: #012456\">\/<\/span><span style=\"color: #fff;background-color: #012456\">29<\/span><span style=\"color: #888;background-color: #012456\">\/<\/span><span style=\"color: #fff;background-color: #012456\">2014<\/span>  <span style=\"color: #ff0;background-color: #012456\">12:28<\/span> AM       <span style=\"color: #fff;background-color: #012456\">1613<\/span> CommandExecution.log                                                   \r\n <span style=\"color: #888;background-color: #012456\">-a---<\/span>         7\/28\/2014  11:59 PM       <span style=\"color: #fff;background-color: #012456\">1429<\/span> CommandExecution_0.log                                                 \r\n <span style=\"color: #888;background-color: #012456\">-a---<\/span>         7\/29\/2014  12:01 AM       <span style=\"color: #fff;background-color: #012456\">2113<\/span> CommandExecution_1.log                                                 \r\n <span style=\"color: #888;background-color: #012456\">-a---<\/span>         7\/29\/2014  12:02 AM       <span style=\"color: #fff;background-color: #012456\">1613<\/span> CommandExecution_2.log                                                 \r\n <span style=\"color: #888;background-color: #012456\">-a---<\/span>         7\/29\/2014  12:28 AM      <span style=\"color: #fff;background-color: #012456\">13744<\/span> DSCBOOT_script_20140729-002759.log                                     \r\n <span style=\"color: #888;background-color: #012456\">-a---<\/span>         7\/29\/2014  12:03 AM     <span style=\"color: #fff;background-color: #012456\">473528<\/span> DSCLOG_metaconf__20140729-000322.json                                  \r\n <span style=\"color: #888;background-color: #012456\">-a---<\/span>         7\/29\/2014  12:28 AM     <span style=\"color: #fff;background-color: #012456\">713196<\/span> DSCLOG_metaconf__20140729-002823.json                                  \r\n <span style=\"color: #888;background-color: #012456\">-a---<\/span>         7\/29\/2014  12:03 AM     <span style=\"color: #fff;background-color: #012456\">608050<\/span> DSCLOG__20140729-000311.json                                           \r\n <span style=\"color: #888;background-color: #012456\">-a---<\/span>         7\/29\/2014  12:28 AM     <span style=\"color: #fff;background-color: #012456\">713196<\/span> DSCLOG__20140729-002826.json                                           \r\n<\/pre>\n<p>As you can see there are a number of various logs present.<\/p>\n<p>\u201cCommandExecution*.log\u201d are logs written by Azure infrastructure as it enabled the DSC extension.<\/p>\n<p>\u201cDSCBOOT_script*.log\u201d is a high level log that applied our configuration that we mentioned previously. It is fairly concise. If everything went well towards the end of the log you should be able to see a line such as this:<\/p>\n<p>VERBOSE: [EXAMPLE-1] Configuration application complete.<\/p>\n<p>If we wish to dig deeper into DSC logs, then the rest of logs can tell us much deeper story. \u201cDSCLOG_*.json\u201d logs are ETL DSC logs converted to JSON format. If configuration has completed successfully you should be able to see an event like this one:<\/p>\n<p>{<\/p>\n<p>&#8220;EventType&#8221;:\u00a0 4,<\/p>\n<p>&#8220;TimeCreated&#8221;:\u00a0 &#8220;\\\/Date(1406593703182)\\\/&#8221;,<\/p>\n<p>&#8220;Message&#8221;:\u00a0 &#8220;[EXAMPLE-1]: LCM:\u00a0 [ End\u00a0\u00a0\u00a0 Set\u00a0\u00a0\u00a0\u00a0\u00a0 ]\u00a0\u00a0\u00a0 in\u00a0 14.1745 seconds.&#8221;,<\/p>\n<p>\u201cDSCLOG_metacong*.json\u201d are the logs for your configuration if your PowerShell DSC configuration had a meta-config that modified PowerShell DSC properties, such as this:<\/p>\n<p>LocalConfigurationManager<\/p>\n<p>{<\/p>\n<p>ConfigurationID = &#8220;646e48cb-3082-4a12-9fd9-f71b9a562d4e&#8221;<\/p>\n<p>RefreshFrequencyMins = 23<\/p>\n<p>}<\/p>\n<p>You would see a similar event if meta configuration was applied successfully.<\/p>\n<p>{<\/p>\n<p>&#8220;EventType&#8221;:\u00a0 4,<\/p>\n<p>&#8220;TimeCreated&#8221;:\u00a0 &#8220;\\\/Date(1406593703182)\\\/&#8221;,<\/p>\n<p>&#8220;Message&#8221;:\u00a0 &#8220;[EXAMPLE-1]: LCM:\u00a0 [ End\u00a0\u00a0\u00a0 Set\u00a0\u00a0\u00a0\u00a0\u00a0 ]\u00a0\u00a0\u00a0 in\u00a0 14.1745 seconds.&#8221;,<\/p>\n<p>&nbsp;<\/p>\n<h5>More info<\/h5>\n<p>Here are some additional resources about PowerShell DSC, Azure VM agent and extensions:<\/p>\n<p><a href=\"http:\/\/blogs.technet.com\/b\/privatecloud\/archive\/2014\/04\/25\/desired-state-configuration-blog-series-part-1-learning-about-dsc.aspx\">Desired State Configuration Blog Series \u2013 Part 1<\/a>, Information about DSC (by Michael Green, Senior Program Manager, Microsoft)<\/p>\n<p><a href=\"http:\/\/azure.microsoft.com\/blog\/2014\/04\/11\/vm-agent-and-extensions-part-1\/\">VM Agent and Extensions &#8211; part 1<\/a> (by Kundana Palagiri, Senior Program Manager, Windows Azure)<\/p>\n<p><a href=\"http:\/\/azure.microsoft.com\/blog\/2014\/04\/15\/vm-agent-and-extensions-part-2\/\">VM Agent and Extensions &#8211; Part 2<\/a> (by Kundana Palagiri, Senior Program Manager, Windows Azure)<\/p>\n<p><a href=\"http:\/\/azure.microsoft.com\/blog\/2014\/04\/24\/automating-vm-customization-tasks-using-custom-script-extension\/\">Automating VM Customization tasks using Custom Script Extension<\/a> (by Kundana Palagiri, Senior Program Manager, Windows Azure)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>UPDATE 11\/4\/2014: For information on using PSCredential objects, please refer to this blog post. UPDATE 11\/21\/2014: For information on OS support, and other features, please refer to our release history. For the latest information regarding DSC Extension, refer to the product\u00a0documentation. &#8230;&#8230;&#8230;. Earlier this year Microsoft released the Azure VM Agent and Extensions as part [&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":[142,150,248,251,345,348],"class_list":["post-1581","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-desired-state-configuration","tag-dsc","tag-powershell","tag-powershell-4-0","tag-windows-powershell-4-0","tag-windows-powershell-desired-state-configuration"],"acf":[],"blog_post_summary":"<p>UPDATE 11\/4\/2014: For information on using PSCredential objects, please refer to this blog post. UPDATE 11\/21\/2014: For information on OS support, and other features, please refer to our release history. For the latest information regarding DSC Extension, refer to the product\u00a0documentation. &#8230;&#8230;&#8230;. Earlier this year Microsoft released the Azure VM Agent and Extensions as part [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1581","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=1581"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/1581\/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=1581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=1581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=1581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}