New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module fails import on Azure Automation account #25
Comments
Have the same problem with the module being loaded in the powershell VSCode module. Same error as in the module load: Import-Module : Mindestens ein Typ in der Assembly kann nicht geladen werden. Rufen Sie die LoaderExceptions-Eigenschaft ab, wenn Sie weitere Informationen benötigen.
(sorry for german error, it says something like - an assembly cannot be loaded and you should retrieve the LoaderException property to get a detailed error) |
Ran into the same issue but after poking around in the LoaderExceptions, it turned out that two assemblies were missing.
It is a bit of a hack job and not very efficient but it runs with the following code. It will download the assemblies and the SDK, load the assemblies and then imports the module.
|
Created a patched version which can be loaded into a runbook using Import-Module. It still refuses to be imported into an Automation Account though.
|
Sounds really great!! I will test it today, for new automations this will be really great, i had to recreated the functions using just Rest API for last job and it was a lot of work. Thanks!!! |
Hi, I'm trying to get this working as well. Could we expect a fix for the Azure Automation import?
Thanks! |
Hi all, We are aware of the failure of importing the module into Azure Automation, we are looking into it. Dave |
Through the LoaderExceptions, found out that it suddenly requires the SignalR.Client version 2.4.0 . You can use the following snippet to import it:
I've tested it with a brand new Automation Account and no other modules are required. |
I am having a similar issue, but am not using Azure Automation.
|
Microsoft.WindowsAzure.Storage seems to be Azure.Storage module according to the Microsoft docs. Maybe try installing it with:
And try again. When you get another exception keep going through the LoaderExceptions to see which one is missing, find the module, install it and try again :) |
Thank you, @HackershubNL. I retried after installing Azure.Storage and its dependency AzureRM.Profile, but the error is the same when trying to import the Microsoft.Graph.Intune module. Still has an issue with the Microsoft.WindowsAzure.Storage assembly |
That's a bit of odd issue. Since it is looking for version 6.2.0 another debugging option would be to download the DLL from the NuGet gallery and importing it by hand:
|
@davefalkus already a plan when this will be resolved or should we still implement some workarounds? |
I'm working with the Azure Automation team to find a solution. I'm not sure when we will get this fixed, but we're actively working on this. In the meantime, I've put some snippets together (thanks @HackershubNL!) to workaround the issue while still using the version of the Intune PowerShell SDK in the PowerShell Gallery: # Get SignalR.Client
wget -uri "https://www.nuget.org/api/v2/package/Microsoft.AspNet.SignalR.Client/2.4.0.0" -outfile "Microsoft.AspNet.SignalR.Client.zip"
Unblock-File Microsoft.AspNet.SignalR.Client.zip
Expand-Archive Microsoft.AspNet.SignalR.Client.zip
Add-Type -Path .\Microsoft.AspNet.SignalR.Client\lib\net45\Microsoft.AspNet.SignalR.Client.dll
# Get Practices.ServiceLocation
wget -uri "https://www.nuget.org/api/v2/package/Cquential.Microsoft.Practices.ServiceLocation/1.0.0" -outfile "Cquential.Microsoft.Practices.ServiceLocation.zip"
Unblock-File Cquential.Microsoft.Practices.ServiceLocation.zip
Expand-Archive Cquential.Microsoft.Practices.ServiceLocation.zip
Add-Type -Path .\Cquential.Microsoft.Practices.ServiceLocation\lib\net35\Microsoft.Practices.ServiceLocation.dll
# Install the module
Write-Host 'Installing...'
Install-Module Microsoft.Graph.Intune -Force -AcceptLicense
# Import the module
Write-Host 'Importing...'
try {
Import-Module Microsoft.Graph.Intune
} catch [System.Reflection.ReflectionTypeLoadException] {
$_.Exception.GetBaseException().loaderexceptions
exit
}
# Log into test tenant
Write-Host 'Logging in...'
$creds = Get-AutomationPSCredential -Name 'your-credential-name' # To create credentials in Azure Automation: https://docs.microsoft.com/en-us/azure/automation/shared-resources/credentials#creating-a-new-credential-asset
Connect-MSGraph -PSCredential $creds
# Run a simple cmdlet (no network traffic)
Write-Host 'Get current MSGraph environment parameters'
Get-MSGraphEnvironment
# Make a call to Microsoft Graph using the cmdlets
Write-Host 'List all mobile apps'
Get-IntuneMobileApp UPDATE: @bmcder rightly mentioned that the "PowerShellGet" module needs to be installed/updated in Azure Automation. This module depends on the "PackageManagement" module, so this needs to be installed first. These modules can be installed into Azure Automation from the Modules Gallery. |
The proposed workaround will not work to import the module into Azure Automation due to the lack of NuGet in that environment. |
@bmcder The NuGet executable should not be required, since we are using the Could you please share the error you are seeing? |
Thanks Rohit for making me re-check this. It was originally failing with an error on this line... Install-Module Microsoft.Graph.Intune -Force -AcceptLicense ...stating that -AcceptLicense was an unknown parameter. On removing that, I received a NuGet related error running the same line (apologies I don't have a copy of that error). Today I engaged my brain and checked the history of the Install-Module command to learn that the -AcceptLicense switch was added in PowerShell v6. So I imported the latest PowerShellGet module (today this is version 2.1.5) into the Automation Account, which required I first import the PackageManagement module (today this is version 1.4.2). After that I added the -AcceptLicense switch back in and all was good :) |
Thanks @bmcder for sharing the fix for your error! Good to know that |
I'm very pleased to say that we were able to work with the Azure Automation team to find a solution. This issue is now fixed in the latest version (6.1907.1.0) of the module on PowerShell Gallery! I was able to run this script in Azure Automation: # Import the module
Write-Host 'Installing...'
Install-Module Microsoft.Graph.Intune -Force -AcceptLicense
# Log into test tenant
Write-Host 'Logging in...'
$creds = Get-AutomationPSCredential -Name 'your-credential-name' # To create credentials in Azure Automation: https://docs.microsoft.com/en-us/azure/automation/shared-resources/credentials#creating-a-new-credential-asset
Connect-MSGraph -PSCredential $creds
# Run a simple cmdlet (no network traffic)
Write-Host 'Get current MSGraph environment parameters'
Get-MSGraphEnvironment
# Make a call to Microsoft Graph using the cmdlets
Write-Host 'List all mobile apps'
Get-IntuneMobileApp I will close this now, but please feel free to keep discussing if there are any more issues. |
Hello,
I am trying to use this module in a Azure automation account with a runbook to automate some daily tasks, but the same fails to import, i have a premier support tickets openned, but for now i had no lucky, do you know if this should works there? if not the reason why it is not compatible?
Also if fails to work the only possible solution is using the intune powershell samples? that are basically REST API calls?
Thank you
The text was updated successfully, but these errors were encountered: