MS Teams connectivity issue in Azure function

%3CLINGO-SUB%20id%3D%22lingo-sub-323850%22%20slang%3D%22en-US%22%3EMS%20Teams%20connectivity%20issue%20in%20Azure%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-323850%22%20slang%3D%22en-US%22%3E%3CP%3EI%20tried%20to%20use%20MS%20Teams%20commandlets%20in%20Azure%20runbook%20and%20got%20the%20below%20error.%20Any%20thoughts%20would%20be%20appreciated.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CSTRONG%3EConnect-MicrosoftTeams%20%3A%20One%20or%20more%20errors%20occurred.%3A%20Unable%20to%20find%20an%20entry%20point%20named%20'GetPerAdapterInfo'%20in%20DLL%20%0A%0A'iphlpapi.dll'.%0A%0AAt%20line%3A14%20char%3A1%0A%0A%2B%20Connect-MicrosoftTeams%20-AccountId%20%22abcd%40testtenant.onmicrosoft.com%22%3C%2FSTRONG%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMS%20Teams%20Module%20version%20used%3A%200.9.6%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-323850%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Teams%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-323958%22%20slang%3D%22en-US%22%3ERe%3A%20MS%20Teams%20connectivity%20issue%20in%20Azure%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-323958%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20are%20you%20passing%20the%20credential%20%3F%20Looks%20like%20you%20are%20just%20suppying%20a%20username%3F%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20show%20how%20to%20create%20a%20runbook%20to%20use%20Teams%20PowerShell%20here%20-%26gt%3B%26nbsp%3B%3CFONT%3E%3CA%20href%3D%22https%3A%2F%2Fregarding365.com%2Fcreate-a-new-team-from-microsoft-flow-61a361ee328a%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fregarding365.com%2Fcreate-a-new-team-from-microsoft-flow-61a361ee328a%3C%2FA%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1548752%22%20slang%3D%22en-US%22%3ERe%3A%20MS%20Teams%20connectivity%20issue%20in%20Azure%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1548752%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F178440%22%20target%3D%22_blank%22%3E%40Steven%20Collier%3C%2FA%3E%26nbsp%3B%20your%20post%20outlines%20how%20use%20connect-microsoftteams%20using%20a%20configured%20credential%26nbsp%3B%20correctly%20but%20I%20believe%20the%20issue%20the%20OP%20is%20posting%20about%20is%20due%20to%20trying%20to%20us%20a%20runas%20account%20or%20some%20other%20connection%20%2B%20certificate%20service%20principal%20account.%26nbsp%3B%20%26nbsp%3BI%20get%20exactly%20the%20same%20error%20and%20have%20seen%20other%20reports%20about%20this%20not%20working%20-%20really%20seems%20like%20you%20cannot%20use%20service%20principal%20to%20connect.%20Have%20you%20ever%20had%20success%20trying%20to%20do%20this%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1552902%22%20slang%3D%22en-US%22%3ERe%3A%20MS%20Teams%20connectivity%20issue%20in%20Azure%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1552902%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F646041%22%20target%3D%22_blank%22%3E%40PhilRiceUoS%3C%2FA%3E%26nbsp%3BI%20haven't%20looked%20in%20to%20using%20Teams%20PowerShell%20using%20a%20Service%20Principal%2C%20I%20would%20doubt%20it's%20possible.%20For%20provisioning%20I%20now%20typically%20register%20an%20application%20and%20then%20use%20a%20Client%20Secret%20to%20authenticate%20then%20call%20the%20Graph%20APIs%20I%20need%20directly.%20Lee%20Ford%20describes%20this%20well%20at%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fwww.lee-ford.co.uk%2Fgetting-started-with-microsoft-graph-with-powershell%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fwww.lee-ford.co.uk%2Fgetting-started-with-microsoft-graph-with-powershell%2F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThere%20are%20lots%20of%20Teams%20capabilities%20currently%20only%20available%20through%20the%20beta%20api%2C%20for%20example%20templates.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESteven%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1553421%22%20slang%3D%22en-US%22%3ERe%3A%20MS%20Teams%20connectivity%20issue%20in%20Azure%20function%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1553421%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F178440%22%20target%3D%22_blank%22%3E%40Steven%20Collier%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Steven%20%2C%20strangely%20it%20is%20good%20to%20hear%20that%20you%20doubt%20it%20is%20possible%20as%20I%20have%20come%20to%20that%20conclusion%20myself%20after%20lots%20of%20testing%20without%20success.%20Graph%20Api%20wont%20work%20in%20my%20particular%20use%20case%20as%20Im%20using%20Automation%20to%20apply%20Teams%20App%20Permission%20policies%20and%20Graph%20Api%20doesnt%20yet%20have%20the%20ability%20to%20deal%20with%20Teams%20Policies%20yet%20from%20what%20Ive%20seen.%3C%2FP%3E%3CP%3EThe%20Teams%20powershell%20module%20does%20seem%20to%20be%20getting%20new%20features%20to%20help%20with%20this%20though%20and%20Ive%20used%20the%26nbsp%3BNew-CsGroupPolicyAssignment%20cmdlet%20for%20assigning%20Custom%20App%20Setup%20policy%20to%20a%20security%20group%20%2C%20but%20it%20doesn%20work%20for%20Custom%20App%20Permissions%20policies%20yet.%20When%20it%20does%20then%20I%20wont%20need%20to%20script%20this%20anymore%20but%20for%20now%2C%20another%20new%20cmdlet%26nbsp%3BNew-CsBatchPolicyAssignmentOperation%20works%20nicely%26nbsp%3B%20for%20that.%3C%2FP%3E%3CP%3EAs%20the%20runas%20approach%20doesnt%20work%20Im%20taking%20a%20different%20approach%20to%20secure%20things%20and%20am%20now%20going%20to%20setup%20a%20workflow%20script%20that%20other%20scripts%20will%20call%20to%20request%20to%20create%20an%20account%2C%20set%20password%20and%20assign%20a%20role%20and%20then%20call%20again%20to%20delete%20the%20account%20once%20the%20script%20has%20completed.%20That%20way%20can%20use%20a%20random%20account%20name%20and%20password%20running%20with%20a%20custom%20role%20that%20is%20basically%20using%20Just%20in%20Time%20Access%20%2C%20probably%20even%20more%20secure%20than%20having%20a%20runas%20account.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I tried to use MS Teams commandlets in Azure runbook and got the below error. Any thoughts would be appreciated.

 

Connect-MicrosoftTeams : One or more errors occurred.: Unable to find an entry point named 'GetPerAdapterInfo' in DLL 

'iphlpapi.dll'.

At line:14 char:1

+ Connect-MicrosoftTeams -AccountId "abcd@testtenant.onmicrosoft.com"

 

MS Teams Module version used: 0.9.6

 

4 Replies
Highlighted

How are you passing the credential ? Looks like you are just suppying a username?

 

I show how to create a runbook to use Teams PowerShell here -> https://regarding365.com/create-a-new-team-from-microsoft-flow-61a361ee328a

 

 

Highlighted

@Steven Collier  your post outlines how use connect-microsoftteams using a configured credential  correctly but I believe the issue the OP is posting about is due to trying to us a runas account or some other connection + certificate service principal account.   I get exactly the same error and have seen other reports about this not working - really seems like you cannot use service principal to connect. Have you ever had success trying to do this?

Highlighted

@PhilRiceUoS I haven't looked in to using Teams PowerShell using a Service Principal, I would doubt it's possible. For provisioning I now typically register an application and then use a Client Secret to authenticate then call the Graph APIs I need directly. Lee Ford describes this well at https://www.lee-ford.co.uk/getting-started-with-microsoft-graph-with-powershell/

 

There are lots of Teams capabilities currently only available through the beta api, for example templates. 

 

Steven

Highlighted

 

@Steven Collier 

Hi Steven , strangely it is good to hear that you doubt it is possible as I have come to that conclusion myself after lots of testing without success. Graph Api wont work in my particular use case as Im using Automation to apply Teams App Permission policies and Graph Api doesnt yet have the ability to deal with Teams Policies yet from what Ive seen.

The Teams powershell module does seem to be getting new features to help with this though and Ive used the New-CsGroupPolicyAssignment cmdlet for assigning Custom App Setup policy to a security group , but it doesn work for Custom App Permissions policies yet. When it does then I wont need to script this anymore but for now, another new cmdlet New-CsBatchPolicyAssignmentOperation works nicely  for that.

As the runas approach doesnt work Im taking a different approach to secure things and am now going to setup a workflow script that other scripts will call to request to create an account, set password and assign a role and then call again to delete the account once the script has completed. That way can use a random account name and password running with a custom role that is basically using Just in Time Access , probably even more secure than having a runas account.