In this post I will walk you through the process of installing .NET 3.5 with Azure DSC. A few OS versions back Microsoft decided to remove the source .cab for .NET 3.5 from Windows Server. Reasons for removing the source files or installing .NET 3.5 at all aside, you probably landed on this page because you want to deploy .NET 3.5 with Azure Desired State Configuration but running into trouble.
The source of the issue is the “Removed” install state for .NET Framework 3.5. You can see this by running the PowerShell command
Get-WindowsFeature -name NET*
The manual install of .NET 3.5 is as simple as mounting the install media and pointing at the \sources\sxs\ directory. Not so simple with Desired State Configuration. The good news is it’s not that difficult either. And once you set it up, subsequent installs become a snap. Below I walk through the process for Microsoft Windows Server 2016. The steps are probably similar for 2012 R2.
Step 1, upload the .cab file
You need access to the source media and an Azure Storage account for this step. Log into the Azure portal and go to the storage account of your choice and open Files. Create a new file share, I’m naming mine sxs2016.
Now it’s time to upload the .cab file. Open the file share you just created and select upload. Navigate to the source media (D: in my case) D:\source\sxs select and upload the cab file.
Once it’s uploaded, go to the properties of the share, copy and save the URL for later. It should look like the line below.
https://storagesample.file.core.windows.net/sxs2016
Next, go back to the storage account and go to Access Keys. You will need two items from this page, the Storage Account Name and an Access key. Make note of the account name and one of the keys for the next step.
*Note that you will need to update the next steps if you regenerate the storage key.
Step 2, authentication
Now that the file is uploaded and you have account settings, go back to your Azure Automation account and open Credentials.
Give the credential set a name and make a note of it, you will need it when you compile the DSC configuration. Enter the storage account name (noted in step 1) as the user name, and the Access key as the password. Save and move to the next step.
Step 3, DSC file resource
The next step will tell DSC to place the file from Azure File servers onto the server. To start, we need to add a mandatory parameter for the storage account.
Param ( [parameter(Mandatory = $true)] [PSCredential]$storageCredentials )
After that, go to the Node section and add two file resources as shown below.
################################### # File Copy Section # Copy .NET 3.5 source for feature install ################################### File NETSource { Type = "directory" DestinationPath = "C:\NETSource" Ensure = "Present" } File DotNet351SXS { Credential = $storageCredentials DestinationPath = "C:\NETSource\microsoft-windows-netfx3-ondemand-package.cab" SourcePath = "\\storagesample.file.core.windows.net\netsxs\microsoft-windows-netfx3-ondemand-package.cab" Type = "File" Ensure = "Present" DependsOn = "[File]NETSource" }
The first File resource, NETSource, creates the directory on the local server for the .cab file.
The second File resource, DotNet351SXS uses the credentials (account name and access key) to copy the file from the Azure file source to the local C:\drive.
A couple things to note on the second File resource. You need to specify the file name on both the source and destination path. The source path is the same as the URL copied in the first step, only modified from a URL to a UNC path for the file copy operation. Also, I added a DependsOn statement to verify the destination path exists before the .cab file is copied.
Step 4, Windows Feature
In this step, we enable the Windows Feature for .net 3.5. Unlike other resources a source path is required. I also added a DependsOn statement to make sure the file exists on the server.
WindowsFeature DotNET351 { Name = "NET-Framework-Core" Ensure = "present" Source = "C:\NETSource" DependsOn = "[File]DotNet351SXS" }
Step 5, publish and Compile
Once you have the configuration file finished it’s time to upload it to Azure Automation. Log into the portal and go to DSC Configurations. Add the configuration file created in the previous steps.
After uploading the DSC configuration, you will need to compile it. As you compile the configuration you will be asked for the storage credential. Enter the name you gave the credentials (not the actual storage account name, the name of the credential resource) and compile the file.
That’s it. Providing the configuration compiled successfully, you can apply the configuration to a node in your environment.