azurepowershellazure-functionsmicrosoft-teamsqueuetrigger

How to create a Microsoft Team using a Queue Triggered Azure Function writed in PowerShell?


I want to create a Team by using an azure function triggered by an Azure Queue. Unfortunetly when I run the code it is not working inside the Azure Function.

I'm wondering. Is there a way to create a Microsoft Team using PowerShell inside an Azure Function ?

Import-module MicrosoftTeams
$group = New-Team -MailNickname "teamTitle" -displayname "teamTitle" -Visibility "private"
Add-TeamUser -GroupId $group.GroupId -User "user@etc.com"
New-TeamChannel -GroupId $group.GroupId -DisplayName "General"

Working locally. Not working within the Azure Function.

Bellow the error i'm getting :

ERROR: Import-Module : The specified module 'MicrosoftTeams' was not loaded because no valid
module file was found in any module directory. At D:\home\site\wwwroot\CreateTeam\run.ps1:3
char:1 + Import-Module MicrosoftTeams +  [...]

Thank you


Solution

  • Based on the error message, your Function app does not have the MicrosoftTeams module installed. You need to include a reference to this module to the requirements.psd1 file (see https://learn.microsoft.com/azure/azure-functions/functions-reference-powershell#dependency-management for more details).