This Azure Function allows you to book meeting rooms in Outlook using Microsoft Graph API with application-level authentication.
- .NET 7.0 or later
- Azure Functions Core Tools
- Azure CLI (optional, for deployment)
- An Azure AD application with the following API permissions:
Calendars.ReadWrite(Application permission)User.Read.All(Application permission, for user lookups)
- Clone this repository
- Update
appsettings.jsonwith your Azure AD application details:{ "ClientId": "your-client-id", "ClientSecret": "your-client-secret", "TenantId": "your-tenant-id", "SystemUserEmail": "system-user@yourdomain.com", "RoomEmail": "room@yourdomain.com" } - Set these values as environment variables in your Azure Function App settings when deploying to Azure.
-
Install dependencies:
dotnet restore
-
Run the function locally:
func start
Endpoint: POST /api/BookRoom
Request Body:
{
"subject": "Team Sync",
"content": "Team meeting to discuss project updates",
"start": "2025-08-01T10:00:00",
"end": "2025-08-01T11:00:00",
"timeZone": "W. Europe Standard Time",
"roomEmail": "room301@yourcompany.com",
"attendees": [
{
"email": "user1@yourcompany.com",
"type": "required"
},
{
"email": "user2@yourcompany.com",
"type": "optional"
}
]
}Response:
{
"success": true,
"eventId": "AAMkAG...",
"webLink": "https://outlook.office365.com/...",
"message": "Meeting room booked successfully"
}- Go to Azure Portal > Azure Active Directory > App registrations
- Create a new registration
- Add a client secret
- Add the required API permissions
- Grant admin consent for the permissions
- Note down the Application (client) ID, Directory (tenant) ID, and client secret
az login
az functionapp deployment source config-zip \
--resource-group <resource-group> \
--name <app-name> \
--src <zip-file-path>- Right-click the project
- Select "Publish"
- Follow the wizard to create or select an existing Azure Function App
Logs are written to Application Insights if configured. You can view them in the Azure Portal under your Function App's Monitoring section.
The API returns appropriate HTTP status codes and error messages for different scenarios:
- 400 Bad Request: Invalid input data
- 401 Unauthorized: Authentication failed
- 500 Internal Server Error: Server-side error