{"id":11131,"date":"2015-10-02T12:21:00","date_gmt":"2015-10-02T12:21:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2015\/10\/02\/how-to-use-wmf-4-with-azure-dsc-extension-in-azure-resource-manager-arm\/"},"modified":"2019-03-05T09:24:28","modified_gmt":"2019-03-05T17:24:28","slug":"how-to-use-wmf-4-with-azure-dsc-extension-in-azure-resource-manager-arm","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/how-to-use-wmf-4-with-azure-dsc-extension-in-azure-resource-manager-arm\/","title":{"rendered":"How to use WMF 4 with Azure DSC Extension in Azure Resource Manager (ARM)"},"content":{"rendered":"<div class=\"markdown-body\">\n<h2>Overview<\/h2>\n<p>In version 2.7 of the Azure DSC Extension, we added support to leave your Virtual Machine on the latest supported version of WMF 4.0. This blog will show you how to use this feature in Azure Resource Manager (ARM) templates. For this, I will use the Azure Resource Manger Tools, that were released with Azure SDK 2.6 for .NET. I will assume you already have Visual Studio 2015 setup. I also assume you have read <a href=\"http:\/\/blogs.msdn.com\/b\/powershell\/archive\/2015\/10\/01\/how-to-use-wmf-4-with-azure-dsc-extension-in-azure-cloud-service-manager-asm.aspx\">&#8216;How to use WMF 4 with Azure DSC Extension in Azure Cloud Service Manager (ASM)&#8217;<\/a>, as it describes the meaning of some of the terms. The MSDN topic <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/azure\/dn872471.aspx\">&#8216;Creating and Deploying Azure Resource Group Deployment Projects&#8217;<\/a> has a general walk-though of using the tools I will use in this blog. I would suggest you read though and refer back to this page if you loose you way while\nIn this Example I will show you:<\/p>\n<ol>\n<li>How to setup the SDK for .NET, which will add the tools to Visual Studio 2015 to design and deploy an ARM Template.<\/li>\n<li>How to create an ARM project in Visual Studio<\/li>\n<li>How to add DSC to the ARM template<\/li>\n<li>How to send this JSON to the extension on an existing VM.<\/li>\n<\/ol>\n<h2>Setup Azure SDK for .NET<\/h2>\n<p>If you haven&#8217;t already, download and install the latest Azure SDK for .NET. At the time I wrote this, the current download link for the Azure SDK for .NET was <a href=\"http:\/\/go.microsoft.com\/fwlink\/?linkid=518003&amp;clcid=0x409\">here<\/a>. The current links to download the SDK can be found <a href=\"https:\/\/azure.microsoft.com\/en-us\/downloads\/\">here<\/a>.<\/p>\n<h2>Create a ARM Project<\/h2>\n<p>See the MSDN topic <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/azure\/dn872471.aspx\">&#8216;Creating and Deploying Azure Resource Group Deployment Projects&#8217;<\/a> on how to &#8216;Create Azure Resource Group projects&#8217;.<\/p>\n<h2>Add Powershell DSC Extension<\/h2>\n<p>Once you have created you project, you need to add the &#8216;Powershell DSC Extension&#8217; to the ARM Template.<\/p>\n<ol>\n<li>In <strong>Solution Explorer<\/strong>, expand <strong>templates<\/strong><\/li>\n<li>Click <strong>WindowsVirtualMachine.json<\/strong><\/li>\n<li>Open the <strong>JSON Outline<\/strong> (this is usually on the left hand pane)<\/li>\n<li>In the <strong>JSON Outline<\/strong>, expand <strong>resources<\/strong><\/li>\n<li>In the <strong>JSON Outline<\/strong>, right click <strong>Virtual Machine<\/strong><\/li>\n<li>In the context menu, click <strong>Add New Resource<\/strong><\/li>\n<li>In the <strong>Add Resource Window<\/strong>, click <strong>Powershell DSC Extension<\/strong><\/li>\n<li>In the <strong>Add Resource Window<\/strong>, in the <strong>Name<\/strong> field, type <code>Microsoft.Powershell.DSC<\/code> (Note, this is important for the SDK to work properly.)<\/li>\n<li>In the <strong>Add Resource Window<\/strong>, click Add<\/li>\n<\/ol>\n<p>This should add a section of JSON which looks like this:<\/p>\n<div class=\"highlight highlight-source-js\">\n<pre class=\"lang:default decode:true\">{\r\n    \"\"name\"\": \"\"Microsoft.Powershell.DSC\"\",\r\n    \"\"type\"\": \"\"extensions\"\",\r\n    \"\"location\"\": \"\"[variables('location')]\"\",\r\n    \"\"apiVersion\"\": \"\"2015-05-01-preview\"\",\r\n    \"\"dependsOn\"\": [\r\n        \"\"[concat('Microsoft.Compute\/virtualMachines\/', variables('vmName'))]\"\"\r\n    ],\r\n    \"\"tags\"\": {\r\n        \"\"displayName\"\": \"\"Microsoft.Powershell.DSC\"\"\r\n    },\r\n    \"\"properties\"\": {\r\n        \"\"publisher\"\": \"\"Microsoft.Powershell\"\",\r\n        \"\"type\"\": \"\"DSC\"\",\r\n        \"\"typeHandlerVersion\"\": \"\"2.1\"\",\r\n        \"\"autoUpgradeMinorVersion\"\": true,\r\n        \"\"settings\"\": {\r\n            \"\"modulesUrl\"\": \"\"[concat(parameters('_artifactsLocation'), '\/', 'dsc.zip')]\"\",\r\n            \"\"sasToken\"\": \"\"[parameters('_artifactsLocationSasToken')]\"\",\r\n            \"\"configurationFunction\"\": \"\"[variables('Microsoft.Powershell.DSCConfigurationFunction')]\"\",\r\n            \"\"properties\"\": {\r\n                \"\"nodeName\"\": \"\"[variables('vmName')]\"\"\r\n            }\r\n        },\r\n        \"\"protectedSettings\"\": { }\r\n    }\r\n}<\/pre>\n<\/div>\n<h2>Using the new WMF Version feature<\/h2>\n<h3>Updating the Extension version<\/h3>\n<p>You must make sure you use at least the 2.7 version of the extension. In the DSC Extension JSON update <code>\"typeHandlerVersion\": \"2.1\"<\/code> to <code>\"typeHandlerVersion\": \"2.7\"<\/code>. This will update the DSC Extension version ARM installs from 2.1 to 2.7.<\/p>\n<h3>Adding the property to configure the WMF Version<\/h3>\n<p>You must tell the DSC Extension what version of the WMF you want to use. If you don&#8217;t it will use the latest. In the settings section add a wmfVersion property with the value 4.0. Here is an example <code>\"wmfVersion\": \"[parameters('wmfVersion')]\"<\/code>.\nAfter this the JSON should look like this:<\/p>\n<div class=\"highlight highlight-source-js\">\n<pre class=\"lang:default decode:true\">{\r\n    \"name\": \"Microsoft.Powershell.DSC\",\r\n    \"type\": \"extensions\",\r\n    \"location\": \"[variables('location')]\",\r\n    \"apiVersion\": \"2015-05-01-preview\",\r\n    \"dependsOn\": [\r\n        \"[concat('Microsoft.Compute\/virtualMachines\/', variables('vmName'))]\"\r\n    ],\r\n    \"tags\": {\r\n        \"displayName\": \"Microsoft.Powershell.DSC\"\r\n    },\r\n    \"properties\": {\r\n        \"publisher\": \"Microsoft.Powershell\",\r\n        \"type\": \"DSC\",\r\n        \"typeHandlerVersion\": \"2.1\",\r\n        \"autoUpgradeMinorVersion\": true,\r\n        \"settings\": {\r\n            \"modulesUrl\": \"[concat(parameters('_artifactsLocation'), '\/', 'dsc.zip')]\",\r\n            \"sasToken\": \"[parameters('_artifactsLocationSasToken')]\",\r\n            \"configurationFunction\": \"[variables('Microsoft.Powershell.DSCConfigurationFunction')]\",\r\n            \"wmfVersion\": \"4.0\",\r\n            \"properties\": {\r\n                \"nodeName\": \"[variables('vmName')]\"\r\n            }\r\n        },\r\n        \"protectedSettings\": { }\r\n    }\r\n}<\/pre>\n<\/div>\n<h2>Deploying your configuration<\/h2>\n<p>The solution should include a <code>Microsoft.Powershell.DSCConfiguration.ps1<\/code> which it will deploy using the DSC Extension.\nSee the MSDN topic <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/azure\/dn872471.aspx\">&#8216;Creating and Deploying Azure Resource Group Deployment Projects&#8217;<\/a> on &#8216;Deploying an Azure Resource Group project to an Azure resource group&#8217;.\nFor a more detailed description of how to deploy see the blog <a href=\"http:\/\/blogs.technet.com\/b\/georgewallace\/archive\/2015\/05\/10\/deploying-a-website-with-content-through-visual-studio-with-resource-groups.aspx\">&#8220;Deploying a Website with Content through Visual Studio with Resource Groups&#8221;<\/a><\/p>\n<h2>Summary<\/h2>\n<p>This should be enough to let you choose which version of WMF you want to use with ARM. I&#8217;ve put the solution I built on <a href=\"https:\/\/github.com\/PowerShell\/PowerShell-Blog-Samples\/tree\/master\/2019-09-30-DSC-Extension-v2.7\/ARM\">GitHub<\/a> and turned the WmfVersion into a parameter on the template. This will let you choose what version you want at deployment time. I also modified the default DSC configuration to report the WMF major Version so it&#8217;s easy to verify it is working without logging into the machine.<\/p>\n<h2>Notes<\/h2>\n<p>Windows Server 2016 Technical Preview has the equivalent of WMF 5 already installed. Therefore, specifying WMF 4 for this OS is not a valid option.<\/p>\n<h2>References<\/h2>\n<p>If you want to dive in further on ARM concepts, Greg Oliver has written the blog <a href=\"http:\/\/blogs.msdn.com\/b\/golive\/archive\/2015\/09\/01\/developing-dsc-scripts-for-the-azure-resource-manager-dsc-extension.aspx\">&#8220;Developing DSC scripts for the Azure Resource Manager DSC Extension&#8221;.<\/a><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Overview In version 2.7 of the Azure DSC Extension, we added support to leave your Virtual Machine on the latest supported version of WMF 4.0. This blog will show you how to use this feature in Azure Resource Manager (ARM) templates. For this, I will use the Azure Resource Manger Tools, that were released with [&hellip;]<\/p>\n","protected":false},"author":604,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[101,102],"class_list":["post-11131","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell","tag-azure-dsc-extension","tag-azure-resource-manager"],"acf":[],"blog_post_summary":"<p>Overview In version 2.7 of the Azure DSC Extension, we added support to leave your Virtual Machine on the latest supported version of WMF 4.0. This blog will show you how to use this feature in Azure Resource Manager (ARM) templates. For this, I will use the Azure Resource Manger Tools, that were released with [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/11131","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\/604"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=11131"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/11131\/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=11131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=11131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=11131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}