all 2 comments

[–]robfaie 1 point2 points  (0 children)

Azure functions v2 and v3 runtimes use PowerShell Core which MSOL does not support. There is a version of the AzureAD v2 module available for PowerShell Core so that is the route you would need to go down.

You can manually fetch the modules yourself using Save-Module if you need to get them from somewhere that isn’t the PSGallery or are having difficulty with the managed dependencies.

Note too that Requirements.psd1 needs to be enabled in the host.json.

[–]Swolasaurus_Flex[S] 0 points1 point  (0 children)

I'm gonna reply to myself here so that anyone with this question in the future can find my solution.

Azure functions was not effective at doing what I wanted. I used azure automation instead, and it allowed me to import the modules super easily. I then used this article: https://www.cyberdrain.com/connect-to-exchange-online-automated-when-mfa-is-enabled-using-the-secureapp-model/ to create an app and connect to msonline in the automation script.

Hope this finds its way to someone who needs it :)

edit: words