-
Notifications
You must be signed in to change notification settings - Fork 236
Integrate Azure API Management with your Teams App and export the api to power app
Junjie Li edited this page Jan 3, 2023
·
7 revisions
Azure API Management enables professional developers to publish their Teams App backend service as APIs, and easily export these APIs to the Power Platform (Power Apps and Power Automate) as custom connectors for discovery and consumption by citizen developers.
- A Teams tab app with Azure Functions. Sample
- A client AAD used to visit the backend API. Both the client app and the web API app must be registered in the same tenant.
- Update the bicep file
infra/azure.bicep
to create API management resources.
param apimServiceName string = resourceBaseName
param apimProductName string = resourceBaseName
param apimServiceAuthServerName string = resourceBaseName
param apimApiName string = resourceBaseName
param publisherEmail string
param publisherName string
param apimServiceSku string
var authorizationEndpoint = uri(aadAppOauthAuthorityHost, '${aadAppTenantId}/oauth2/v2.0/authorize')
var tokenEndpoint = uri(aadAppOauthAuthorityHost, '${aadAppTenantId}/oauth2/v2.0/token')
var scope = '${aadApplicationIdUri}/.default'
resource apimService 'Microsoft.ApiManagement/service@2022-04-01-preview' = {
name: apimServiceName
location: location
sku: {
name: apimServiceSku
capacity: 0
}
properties: {
publisherEmail: publisherEmail
publisherName: publisherName
}
}
resource apimServiceProduct 'Microsoft.ApiManagement/service/products@2022-04-01-preview' = {
parent: apimService
name: apimProductName
properties: {
displayName: apimProductName
description: 'Created by TeamsFx.'
subscriptionRequired: false
state: 'published'
}
}
resource apimAuthorizationServers 'Microsoft.ApiManagement/service/authorizationServers@2022-04-01-preview' = {
parent: apimService
name: apimServiceAuthServerName
properties: {
displayName: apimServiceAuthServerName
description: 'Created by TeamsFx.'
clientRegistrationEndpoint: 'http://localhost'
authorizationEndpoint: authorizationEndpoint
authorizationMethods: [
'GET'
'POST'
]
clientAuthenticationMethod: [
'Body'
]
tokenEndpoint: tokenEndpoint
defaultScope: scope
grantTypes: [
'authorizationCode'
]
bearerTokenSendingMethods: [
'authorizationHeader'
]
clientId: aadAppClientId
clientSecret: aadAppClientSecret
}
}
resource api 'Microsoft.ApiManagement/service/apis@2022-04-01-preview' = {
parent: apimService
name: apimApiName
properties: {
displayName: apimApiName
apiRevision: '1'
subscriptionRequired: false
serviceUrl: 'https://apimts010330c5d0api.azurewebsites.net/api'
path: apimApiName
protocols: [
'https'
]
authenticationSettings: {
oAuth2: {
authorizationServerId: apimServiceAuthServerName
}
}
subscriptionKeyParameterNames: {
header: 'Ocp-Apim-Subscription-Key'
query: 'subscription-key'
}
isCurrent: true
}
}
- Update file
infra/azure.parameters.json
to add the new parameters.
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"publisherEmail": {
"value": "[email protected]"
},
"publisherName": {
"value": "[email protected]"
},
"apimServiceSku": {
"value": "Consumption"
}
}
}
- Add the client id of the client AAD to the
authorizedClientApplicationIds
of Function App.
var apimClientAppClientId = '...'
var authorizedClientApplicationIds = '${apimClientAppClientId};${teamsMobileOrDesktopAppClientId};
- Add the client id of the client AAD to the
knownClientApplications
in the fileaad.manifest.template.json
.
{
"id": "${{AAD_APP_OBJECT_ID}}",
"appId": "${{AAD_APP_CLIENT_ID}}",
"knownClientApplications": [
"${{CLIENT_APP_CLIENT_ID}}"
],
...
}
- To configure the client APP registration to access the Teams App Backend API, the permission of Teams App should be added to the client AAD. Here are the detail steps.
- Enable hybrid flows of the client APP registration in the portal.
You can upload the OpenAPI specification of the backend API in Azure Portal according to this document.
Build Custom Engine Copilots
- Build a basic AI chatbot for Teams
- Build an AI agent chatbot for Teams
- Expand AI bot's knowledge with your content
Scenario-based Tutorials
- Send notifications to Teams
- Respond to chat commands in Teams
- Respond to card actions in Teams
- Embed a dashboard canvas in Teams
Extend your app across Microsoft 365
- Teams tabs in Microsoft 365 and Outlook
- Teams message extension for Outlook
- Add Outlook Add-in to a Teams app
App settings and Microsoft Entra Apps
- Manage Application settings with Teams Toolkit
- Manage Microsoft Entra Application Registration with Teams Toolkit
- Use an existing Microsoft Entra app
- Use a multi-tenant Microsoft Entra app
Configure multiple capabilities
- How to configure Tab capability within your Teams app
- How to configure Bot capability within your Teams app
- How to configure Message Extension capability within your Teams app
Add Authentication to your app
- How to add single sign on in Teams Toolkit for Visual Studio Code
- How to enable Single Sign-on in Teams Toolkit for Visual Studio
Connect to cloud resources
- How to integrate Azure Functions with your Teams app
- How to integrate Azure API Management
- Integrate with Azure SQL Database
- Integrate with Azure Key Vault
Deploy apps to production