Skip to content

cAzureStorage causing incompatibility with xCertificate #3

Description

@jadamsowers

I'm writing some DSC to pull files from Azure Storage using cAzureStorage and also install a certificate using xCertificate. If I have both in the same DSC, the presence of a cAzureStorage configuration element causes the xCertificate configuration element to fail. If I remove the cAzureStorage configuration, the problem goes away.

Consider the following DSC:

{
    Import-DscResource -ModuleName cAzureStorage             
    Import-DscResource -ModuleName xCertificate 

    $storageAccountName      = 'myStorageAccount'
    $storageAccountContainer = 'myBlobs'
    $storageAccountKey       = '[redacted]'
    
    $certificatePath         = "c:\dummycert.pfx" 
    $certificateThumbprint   = '[redacted]'
    
    Node "MyServer"
    {
        cAzureStorage certificateFromBlob
        {
            Path                    = "c:\"
            StorageAccountName      = $storageAccountName
            StorageAccountContainer = $storageAccountContainer
            StorageAccountKey       = $storageAccountKey
            Blob                    = "/testfile.txt"
        }
    
        xPfxImport installCertificate
        {
            Thumbprint              = $certificateThumbprint
            Path                    = $certificatePath
            Location                = "LocalMachine"
            Store                   = "WebHosting"     
            Ensure                  = "Present"
        }
    }
}

When I run Start-DscConfiguration -Path .\AzureStorageAndCertificate -Wait -Force -Verbose, I get the following output:

VERBOSE: An LCM method call arrived from computer MyServer with user sid S-1-5-21-223840705-733908879-1540378650-500.
VERBOSE: [MyServer]: LCM:  [ Start  Set      ]
VERBOSE: [MyServer]: LCM:  [ Start  Resource ]  [[cAzureStorage]certificateFromBlob]
VERBOSE: [MyServer]: LCM:  [ Start  Test     ]  [[cAzureStorage]certificateFromBlob]
VERBOSE: [MyServer]:                            [[cAzureStorage]certificateFromBlob] In Test Function
VERBOSE: [MyServer]:                            [[cAzureStorage]certificateFromBlob] Storage Account is: MyStorageAccount
VERBOSE: [MyServer]:                            [[cAzureStorage]certificateFromBlob] Local Path is: .
VERBOSE: [MyServer]:                            [[cAzureStorage]certificateFromBlob] Container is: MyBlobs
VERBOSE: [MyServer]:                            [[cAzureStorage]certificateFromBlob] Blob is: c:\testfile.txt
VERBOSE: [MyServer]:                            [[cAzureStorage]certificateFromBlob] Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\cAzureStorage\1.0.0.1\cAzureStorage.psd1'.
VERBOSE: [MyServer]:                            [[cAzureStorage]certificateFromBlob] Loading 'Assembly' from path 'C:\Program Files\WindowsPowerShell\Modules\cAzureStorage\1.0.0.1\Microsoft.WindowsAzure.Storage.dll'.
VERBOSE: [MyServer]:                            [[cAzureStorage]certificateFromBlob] Loading 'Assembly' from path 'C:\Program Files\WindowsPowerShell\Modules\cAzureStorage\1.0.0.1\Microsoft.WindowsAzure.Storage.dll'.
VERBOSE: [MyServer]:                            [[cAzureStorage]certificateFromBlob] Populating RepositorySourceLocation property for module cAzureStorage.
VERBOSE: [MyServer]: LCM:  [ End    Test     ]  [[cAzureStorage]certificateFromBlob]  in 0.3440 seconds.
VERBOSE: [MyServer]: LCM:  [ Skip   Set      ]  [[cAzureStorage]certificateFromBlob]
VERBOSE: [MyServer]: LCM:  [ End    Resource ]  [[cAzureStorage]certificateFromBlob]
VERBOSE: [MyServer]: LCM:  [ Start  Resource ]  [[xPfxImport]installCertificate]
VERBOSE: [MyServer]: LCM:  [ Start  Test     ]  [[xPfxImport]installCertificate]
VERBOSE: [MyServer]: LCM:  [ End    Test     ]  [[xPfxImport]installCertificate]  in 0.2030 seconds.
PowerShell DSC resource MSFT_xPfxImport  failed to execute Test-TargetResource functionality with error message: Cannot validate argument on parameter 'Thumbprint'. Exception calling "GetTypes" with "0" argument(s): "Unable to 
load one or more of the requested types. Retrieve the LoaderExceptions property for more information." 
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : ProviderOperationExecutionFailure
    + PSComputerName        : MyServer
 
VERBOSE: [MyServer]: LCM:  [ End    Set      ]
The SendConfigurationApply function did not succeed.
    + CategoryInfo          : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName        : MyServer
 
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 1.63 seconds

However, if I comment out the cAzureStorage configuration portion, I get the expected result from xCertificate when applying the configuration:

VERBOSE: An LCM method call arrived from computer MyServer with user sid S-1-5-21-223840705-733908879-1540378650-500.
VERBOSE: [MyServer]: LCM:  [ Start  Set      ]
VERBOSE: [MyServer]: LCM:  [ Start  Resource ]  [[xPfxImport]installCertificate]
VERBOSE: [MyServer]: LCM:  [ Start  Test     ]  [[xPfxImport]installCertificate]
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] '[thumbprint has been redacted from output]' is not a valid hash.
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] '[thumbprint has been redacted from output]' is not a valid hash.
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] '[thumbprint has been redacted from output]' is not a valid hash.
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] '[thumbprint has been redacted from output]' is not a valid hash.
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] '[thumbprint has been redacted from output]' is not a valid hash.
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] '[thumbprint has been redacted from output]' is not a valid hash.
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] Get-TargetResource: Getting Pfx existence '[thumbprint has been redacted from output]' in 'Cert:\LocalMachine\WebHosting'.
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] Test-TargetResource: Testing Pfx '[thumbprint has been redacted from output]' existence in 'Cert:\LocalMachine\WebHosting'.
VERBOSE: [MyServer]: LCM:  [ End    Test     ]  [[xPfxImport]installCertificate]  in 1.3290 seconds.
VERBOSE: [MyServer]: LCM:  [ Start  Set      ]  [[xPfxImport]installCertificate]
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] '[thumbprint has been redacted from output]' is not a valid hash.
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] '[thumbprint has been redacted from output]' is not a valid hash.
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] '[thumbprint has been redacted from output]' is not a valid hash.
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] Set-TargetResource: Setting Pfx '[thumbprint has been redacted from output]' existence in 'Cert:\LocalMachine\WebHosting'.
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] Performing the operation "Set-TargetResource" on target "Importing Pfx 'c:\dummycert.pfx' into 'Cert:\LocalMachine\WebHosting'".
VERBOSE: [MyServer]:                            [[xPfxImport]installCertificate] Set-TargetResource: Importing Pfx 'c:\dummycert.pfx' into 'Cert:\LocalMachine\WebHosting'.
VERBOSE: [MyServer]: LCM:  [ End    Set      ]  [[xPfxImport]installCertificate]  in 0.5150 seconds.
VERBOSE: [MyServer]: LCM:  [ End    Resource ]  [[xPfxImport]installCertificate]
VERBOSE: [MyServer]: LCM:  [ End    Set      ]
VERBOSE: [MyServer]: LCM:  [ End    Set      ]    in  2.0000 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.
VERBOSE: Time taken for configuration job to complete is 2.088 seconds

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions