PowerShell modules
azureautomation / modules Goto Github PK
View Code? Open in Web Editor NEWPowerShell modules
PowerShell modules
The initial download of resources works fine, but then the following error comes up after the next download:
{"time": "2017-07-18T08:08:02.646+00:00", "type": "verbose", "message": "[SERVER01]: LCM: [ Start Resource ] [[cAzureStorage]DownloadResources] "}, {"time": "2017-07-18T08:08:02.646+00:00", "type": "verbose", "message": "[SERVER01]: LCM: [ Start Test ] [[cAzureStorage]DownloadResources] "}, {"time": "2017-07-18T08:08:02.646+00:00", "type": "verbose", "message": "[SERVER01]: [[cAzureStorage]DownloadResources] In Test Function"}, {"time": "2017-07-18T08:08:02.646+00:00", "type": "verbose", "message": "[SERVER01]: [[cAzureStorage]DownloadResources] Storage Account is: ctc001sa"}, {"time": "2017-07-18T08:08:02.662+00:00", "type": "verbose", "message": "[SERVER01]: [[cAzureStorage]DownloadResources] Local Path is: C:\\JDE\\DSCResources"}, {"time": "2017-07-18T08:08:02.662+00:00", "type": "verbose", "message": "[SERVER01]: [[cAzureStorage]DownloadResources] Container is: dscresources"}, {"time": "2017-07-18T08:08:02.662+00:00", "type": "verbose", "message": "[SERVER01]: [[cAzureStorage]DownloadResources] Blob is: "}, {"time": "2017-07-18T08:08:02.662+00:00", "type": "verbose", "message": "[SERVER01]: [[cAzureStorage]DownloadResources] Loading module from path 'C:\\Program Files\\WindowsPowerShell\\Modules\\cAzureStorage\\1.0.0.1\\cAzureStorage.psd1'."}, {"time": "2017-07-18T08:08:02.662+00:00", "type": "verbose", "message": "[SERVER01]: [[cAzureStorage]DownloadResources] Loading 'Assembly' from path 'C:\\Program Files\\WindowsPowerShell\\Modules\\cAzureStorage\\1.0.0.1\\Microsoft.WindowsAzure.Storage.dll'."}, {"time": "2017-07-18T08:08:02.662+00:00", "type": "verbose", "message": "[SERVER01]: [[cAzureStorage]DownloadResources] Loading 'Assembly' from path 'C:\\Program Files\\WindowsPowerShell\\Modules\\cAzureStorage\\1.0.0.1\\Microsoft.WindowsAzure.Storage.dll'."}, {"time": "2017-07-18T08:08:03.006+00:00", "type": "verbose", "message": "[SERVER01]: [[cAzureStorage]DownloadResources] Need to download Install1.exeas it is different then the local file"}, {"time": "2017-07-18T08:08:03.115+00:00", "type": "verbose", "message": "[SERVER01]: [[cAzureStorage]DownloadResources] Need to download Install2.msias it is different then the local file"}, {"time": "2017-07-18T08:08:03.381+00:00", "type": "verbose", "message": "[SERVER01]: [[cAzureStorage]DownloadResources] Need to download Install3.exeas it is different then the local file"}, {"time": "2017-07-18T08:08:03.381+00:00", "type": "verbose", "message": "[SERVER01]: LCM: [ End Test ] [[cAzureStorage]DownloadResources] False in 0.7340 seconds."}, {"time": "2017-07-18T08:08:03.381+00:00", "type": "verbose", "message": "[SERVER01]: LCM: [ End Resource ] [[cAzureStorage]DownloadResources] "},
The content on the Azure Storage and on the drive are exactly the same, but this ends with a fail (Need to download XXXXXXX as it is different then the local file). I can't find out what's going wrong here.
Trying to perform some updates to CosmosDB with the Azure automation run books. I have made a RunAs service principal Account to authenticate with Azure
Updating the Modules used for the Get-AzureRmResource appear to cause some issues where I can no longer retrieve the CosmosDB object.
From a plain automation account with the powershell modules of v1.0.3 the Process of update my runbook module is I look for the AzureRM.WebSite module. Currently Version 5.0.3; I click import, then I check the box for importing dependency modules that need update as well.
my runbook code is as follows.
$Conn = Get-AutomationConnection -Name "AzureRunAsConnection"
Add-AzureRmAccount -ServicePrincipal -Tenant $Conn.TenantID `
-ApplicationID $Conn.ApplicationID -CertificateThumbprint
$Conn.CertificateThumbprint
Select-AzureRmSubscription -SubscriptionName "Visual Studio Enterprise" -ErrorAction SilentlyContinue
#resource and app variables declared here.
$cosmosDbResource = (Get-AzureRmResource -ResourceType
"Microsoft.DocumentDb/DatabaseAccounts" -ResourceGroup $applicationGroup -
ApiVersion "2015-04-08" -Name $cosmosDBName)
"Before CosmosDB Resource"
$cosmosDbResource | FT
"Cosmos DB Properties"
$cosmosDbResource.Properties
This code works just fine on the plain deployment of automation accounts with the module. AzureRM.Resources at 1.0.3.
I think that there may be a conflict with the powershell modules with the update
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.