Comments (4)
Requirements.psd1
@{
# For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. Uncomment the next line and replace the MAJOR_VERSION, e.g., 'Az' = '5.'
#'Az' = '11.'
'AzAuth' = '2.'
'AzTable' = '2.'
'Az.Accounts' = '2.'
'Az.Resources' = '6.'
'Az.Storage' = '5.'
'Az.KeyVault' = '4.'
#'AzureAD' = '2.'
'ExchangeOnlineManagement' = '3.'
'MicrosoftTeams' = '4.'
#'Microsoft.Graph' = '2.15.0'
'Microsoft.Graph.Groups' = '2.'
'Microsoft.Graph.Authentication' = '2.'
'Microsoft.Graph.Users' = '2.'
}
from azure-functions-powershell-worker.
Hi @RRanks,
Upon initial review, it appears most likely to me that your issue is a dependency conflict within your modules, and not a return of the platform issue from #1010. This type of error is somewhat common in PowerShell functions which use more than a handful of dependent packages, due to PowerShell loading all modules and their required binaries into the default assembly load context.
We are working on publishing a user guide for this scenario, but our general recommendation for avoiding/preventing these types of errors is as follows:
- Figure out which of the modules from requirements.psd1 utilize the .dll which is in conflict (in this case, Microsoft.Identity.Client). You can utilize Save-Module on your local machine to download the modules and examine their contents to figure out if they are using this dll and which version they use.
- Pin these modules to a specific minor version to prevent the managed dependencies feature from auto-upgrading them and introducing breaking conflicts.
- In profile.ps1, explicitly import each module using Import-Module with the -RequiredVersion parameter. Import the modules in order from highest Microsoft.Identity.Client version to lowest.
- Run the function app. If you are still getting errors, take note of which Import-Module statement is failing, and move it higher in the list.
If you are unable to resolve the issue using these steps, you may have a circular dependency conflict. At this point, there are some further alternatives.
Either
a) You could try running fragile modules in windows compatibility mode. This will isolate those modules into their own powershell instance and therefore, their own assembly load context. Instructions and disclaimers for this approach can be found here
or
b) Splitting the function app into multiple apps each using minimal sets of modules can help prevent modules from conflicting with each other.
If none of these approaches are successful or acceptable, please reach out to our Azure support staff who may be able to further assist. https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request
from azure-functions-powershell-worker.
Hi @RRanks, Upon initial review, it appears most likely to me that your issue is a dependency conflict within your modules, and not a return of the platform issue from #1010. This type of error is somewhat common in PowerShell functions which use more than a handful of dependent packages, due to PowerShell loading all modules and their required binaries into the default assembly load context. We are working on publishing a user guide for this scenario, but our general recommendation for avoiding/preventing these types of errors is as follows:
- Figure out which of the modules from requirements.psd1 utilize the .dll which is in conflict (in this case, Microsoft.Identity.Client). You can utilize Save-Module on your local machine to download the modules and examine their contents to figure out if they are using this dll and which version they use.
- Pin these modules to a specific minor version to prevent the managed dependencies feature from auto-upgrading them and introducing breaking conflicts.
- In profile.ps1, explicitly import each module using Import-Module with the -RequiredVersion parameter. Import the modules in order from highest Microsoft.Identity.Client version to lowest.
- Run the function app. If you are still getting errors, take note of which Import-Module statement is failing, and move it higher in the list.
If you are unable to resolve the issue using these steps, you may have a circular dependency conflict. At this point, there are some further alternatives.
Either
a) You could try running fragile modules in windows compatibility mode. This will isolate those modules into their own powershell instance and therefore, their own assembly load context. Instructions and disclaimers for this approach can be found here
or
b) Splitting the function app into multiple apps each using minimal sets of modules can help prevent modules from conflicting with each other.
If none of these approaches are successful or acceptable, please reach out to our Azure support staff who may be able to further assist. https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request
I FOUND THE ISSUE >> Seems to be the file location changes. And unable to use the "-RequiredVersion" parameter to call an older version
None of the above resolved the issue.. here is what I have found...
I setup a function with just Import-Az.Accounts using the older required version that was working with the previous issue 5months ago. V2.13.2.
It then errored saying it was using V2.16, and Microsoft confirmed it will import the latest version of Az.Accounts no matter what version I add the required value as.
However... The V2.16.0 does not have the same internal folder structure so the fix in #1010 - Is not causing this issue in.. the new version as all the files are in the "netstandard2.0" folder not "netcoreapp2.1" and not "netcoreapp3.1".
Without the patch from the #1010 - It does not work however.. the fix now needs to be updated to the correct path:
Import-Module Az.Accounts
$azAccountsLibPath = Join-Path (Split-Path (Get-Module Az.Accounts).Path -Parent) "lib"
Add-Type -AssemblyName (Join-Path $azAccountsLibPath "netstandard2.0" "Microsoft.IdentityModel.Abstractions.dll")
Add-Type -AssemblyName (Join-Path $azAccountsLibPath "netstandard2.0" "Microsoft.Identity.Client.dll")
Add-Type -AssemblyName (Join-Path $azAccountsLibPath "netstandard2.0" "Microsoft.Identity.Client.Extensions.Msal.dll")
Connect-AzAccount -Identity
error when trying to use RequiredVersion: V2.13.2
2024-04-02T03:44:56Z [Error] ERROR: Could not load file or assembly 'C:\home\data\ManagedDependencies\2404020332440659854.r\Az.Accounts\2.16.0\lib\netcoreapp2.1\Microsoft.Identity.Client.dll'. The system cannot find the file specified.
More screen shots attached..
from azure-functions-powershell-worker.
Oh I also dropped the Graph connections back down to the 5 months ago version.. not tested upgrading them again yet.
'Microsoft.Graph.Groups' = '2.9.1'
'Microsoft.Graph.Authentication' = '2.9.1'
'Microsoft.Graph.Users' = '2.9.1'
'Microsoft.Graph.Education' = '2.9.1'
'Microsoft.Graph.Calendar' = '2.9.1'
from azure-functions-powershell-worker.
Related Issues (20)
- Component Detection: Medium Severity - Microsoft.Azure.DocumentDB.Core HOT 1
- Backport deprecated component replacement to PS7.2 HOT 1
- Update the function app in E2E tests to use latest Extension bundles HOT 1
- Update PowerShell language worker build to check and flag vulnerabilities in the resolved dependencies
- Upgrade PowerShell 7.4 SDK to 7.4.0
- Upgrade PowerShell SDK to latest version
- Update PowerShell 7.0 worker to latest System.Data.SqlClient HOT 1
- Known regression: Durable Functions Activity input fails to deserialize when the input is an array
- [Linux Consumption] [Portal] Portal shows Linux Consumption as an option for Powershell 7.4 it is not supported HOT 3
- [Linux Elastic Premium] Kudu SSH appears to fail for powershell7.4 HOT 3
- Linux (Consumption) not supported in PowerShell 7.4 yet HOT 1
- Feature Request: Recursive Directory Searching for function.json HOT 1
- Support OpenTelemetry in the PowerShell worker
- Profile.ps1 not instrumented HOT 1
- Diagram of module interaction w/ worker HOT 1
- Update PowerShell SDK for 7.4 to 7.4.2
- Update PowerShell SDK for 7.2 to 7.2.19 HOT 1
- Document OpenTelemetry support HOT 1
- Workaround for issue with hosting Durable Functions app on preview Flex Consumption plan
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-functions-powershell-worker.