No description
Find a file
2025-07-10 10:57:31 +03:00
note-assets Initial commit: add sample application for teams meeting management 2025-07-10 10:57:31 +03:00
.gitignore Initial commit: add sample application for teams meeting management 2025-07-10 10:57:31 +03:00
Meetings.csproj Initial commit: add sample application for teams meeting management 2025-07-10 10:57:31 +03:00
Program.cs Initial commit: add sample application for teams meeting management 2025-07-10 10:57:31 +03:00
README.md Initial commit: add sample application for teams meeting management 2025-07-10 10:57:31 +03:00
Settings.cs Initial commit: add sample application for teams meeting management 2025-07-10 10:57:31 +03:00
settings.json Initial commit: add sample application for teams meeting management 2025-07-10 10:57:31 +03:00
TeamsMeetingRequest.cs Initial commit: add sample application for teams meeting management 2025-07-10 10:57:31 +03:00
Utils.cs Initial commit: add sample application for teams meeting management 2025-07-10 10:57:31 +03:00

Creating Teams Meeting With Dotnet

In his sample project I am attempting to create a Teams meeting using the Microsoft Graph API with .NET.

The application should manage most of the process for you. What you need to do is fill out the pre-requisites, copy data to appsettings.json, and run the application. You might be required to create an application access policy in Teams PowerShell. This app will error out if that is needed.

Prerequisites

  • dotnet 6.0 or later
  • Microsoft Graph API access
    • this requires an Azure AD application with the appropriate permissions to create Teams meetings.
    • You can register an application in the Azure portal and grant it the OnlineMeetings.ReadWrite permission.

Registering an application

  1. Go to the Entra id applications view.
  2. Click on "New registration".
  3. Fill in the application name and redirect URI (if needed).
  4. Click "Register".
  5. Once registered, note the Application (client) ID and Directory (tenant) ID.
  6. Under "Certificates & secrets", create a new client secret and note it down. This will be used for authentication.
  7. Under "API permissions", add the OnlineMeetings.ReadWrite permission. You may need to grant admin consent for this permission.

01_app_registration_permissions.png

At this point you should have three separate pieces of information:

  • Application (client) ID: This is the unique identifier for your application.
  • Directory (tenant) ID: This is the identifier for your Azure AD tenant.
  • Client secret: This is the secret key used to authenticate your application.

Filling out the appsettings.json

Sample:

{
  "TenantId": "",
  "ClientId": "",
  "ClientSecret": ""
}

Creating an application access policy

First step is to install some powershell modules. Mainly the MicrosoftTeams module.

Install-Module -Name MicrosoftTeams -Force -AllowClobber

Then we need to connect to Teams PowerShell:

Connect-MicrosoftTeams

If you get an error like this:

Connect-MicrosoftTeams : The 'Connect-MicrosoftTeams' command was found in the module 'MicrosoftTeams', but the 
module could not be loaded. For more information, run 'Import-Module MicrosoftTeams'.
At line:1 char:1
+ Connect-MicrosoftTeams

You need to set execution policy to allow running scripts:

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

Then you can run the Connect-MicrosoftTeams command again.

The command will pop up a login window where you can enter your credentials. Use the admin credentials for the tenant.

02_application_policy.png

Once connected, you can create the application access policy with the following command:

New-CsApplicationAccessPolicy -Identity "TeamsMeetingAccessPolicy" -AppIds "[CLIENT ID FROM APP REGISTRATION]" -Description "Allow this app to create meetings"

This command allows the application with the specified client ID to create Teams meetings.

But in order for the application to create meetings on behalf of a user, the app needs to be given authorization to do so.

Assigning the application access policy to a user

You can assign the application access policy to a user with the following command:

Grant-CsApplicationAccessPolicy -PolicyName "TeamsMeetingAccessPolicy" -Identity [USER PRINCIPAL NAME]

03_application_policy_assigned.png

Runnin the app

Once you have filled out the appsettings.json file and created the application access policy, you can run the application. You can run the application using the following command:

dotnet run

On a successful run, you should see a message indicating that the Teams meeting was created successfully.

04_successful_run.png

About licensing

When you create a new user via Entra ID, you are not necessarily automatically assigned a lisence. This is something that needs to be done separately. So if you login with your newly created user and teams tells you that you can't do that, check the lisences.

05_lisences.png