2
votes

I have created a simple DSC script which is the standard one I assume for downloading IIS.

configuration IISInstall 
{ 
    node VISUALSTUDIOVM

    { 
        WindowsFeature IIS 
        { 
            Ensure = "Present" 
            Name = "Web-Server"                        
        } 
    } 
}

I am trying to create an Azure virtual machine from Powershell.

What I do is:

  1. I upload this configuration file to my azure storage account.

    Publish-AzureVMDscConfiguration -ConfigurationPath C:\AzureVirtualNetwork\Installiis.ps1 -StorageContext $context -Force
    
  2. I create a $vm variable and set the DSC extension

    $vm = Set-AzureVMDSCExtension -VM $vm -ConfigurationArchive "Installiis.ps1.zip"
    
  3. I then update the $vm

    $vm | Update-AzureVM
    

I get the operation success message, but the IIS does not get installed on the machine.

Am I missing something. The $vm I create is Windows server 2012 R2 machine.

The same DSC script when I run from after creating my machine using Start-DscConfiguration and specifying the MOF path it works fine.

The log on the target machine is as follows:

When I check the log file , I get this error, what needs to be done

[01/14/2015 23:34:20.81] Executing: C:\Packages\Plugins\Microsoft.Powershell.DSC\1.5.0.0\bin\enable.cmd [01/14/2015 23:34:23.14] Execution Complete.

#

Execution Output: VERBOSE: Verifying OS Version... VERBOSE: OS Version: 6.3.9600.0 VERBOSE: Server OS: True VERBOSE: OS is supported; enabling extension.

Execution Error: C:\Packages\Plugins\Microsoft.Powershell.DSC\1.5.0.0\bin\enable.ps1 : Error enabling the DSC Extension: The DSC Extension was not installed correctly, please check the logs on the VM. At C:\Packages\Plugins\Microsoft.Powershell.DSC\1.5.0.0\bin\pre-enable.ps1:51 char:5 + & $scriptRoot\enable.ps1 -Verbose + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,enable.ps1

#

Command C:\Packages\Plugins\Microsoft.Powershell.DSC\1.5.0.0\bin\enable.cmd of Microsoft.Powershell.DSC has exited with Exit code: 0 plugin (name: Microsoft.Powershell.DSC, version: 1.5.0.0) completed successfully.

2
Have you tried this on more than one VM to see if it always fails?Simon W
Yup, it always fail :(Chirag Chheda
What if you change the node name to localhost? node localhostkevmar
Its still not working. Only if acquire my target machine from remote powershell session I am able to run the script. One thing what I noticed is when I observe my virtual machine on the Azure dashboard it shows me error on the DSC extension . I am not sure if that is causing the problem, because the same dsc script when executed from target machine it works fine.Chirag Chheda
Can you try removing the DSC extension in the azure portal? We had this problem here and solved it by removing it and letting it reinstall automatically. Also make sure no one is logged in the vm. I think if there are sessions there the machine will not be able to update the extension properly.julealgon

2 Answers

1
votes

Two things I would recommend:

  1. @kevmar is correct, the node localhost is correct
  2. Try a later O/S version. The O/S your on is running 1.5.0.0 of the DSC extension although there is at least 1.9.0.0 version. Try a guest VM image -ImageName 'a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201502.01-en.us-127GB.vhd' or later.
0
votes

I would also check the name of you .zip file in your storage container. Azure storage uses lowercase. when you run the command:

$vm = Set-AzureVMDSCExtension -VM $vm -ConfigurationArchive "Installiis.ps1.zip"

change the .zip name to "installiis.ps1.zip"