Visit Azure
- Bot Service to register your bot and add it to
- various channels. The bot's endpoint URL typically looks
- like this:
-
https://your_bots_hostname/api/messages
-
-
-
-
-
-
-
-
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/.gitignore b/samples/bot-adaptive-card-actions/csharp/M365Agent/.gitignore
new file mode 100644
index 0000000000..c5cae9258c
--- /dev/null
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/.gitignore
@@ -0,0 +1,10 @@
+# TeamsFx files
+build
+appPackage/build
+env/.env.*.user
+env/.env.local
+appsettings.Development.json
+.deployment
+
+# User-specific files
+*.user
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/M365Agent.atkproj b/samples/bot-adaptive-card-actions/csharp/M365Agent/M365Agent.atkproj
new file mode 100644
index 0000000000..124eb75046
--- /dev/null
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/M365Agent.atkproj
@@ -0,0 +1,9 @@
+
+
+
+ b069b3bd-f6bc-cc40-82ab-3fcc2ea50fdf
+
+
+
+
+
\ No newline at end of file
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/M365Agent.ttkproj b/samples/bot-adaptive-card-actions/csharp/M365Agent/M365Agent.ttkproj
deleted file mode 100644
index e3ffdc6c0c..0000000000
--- a/samples/bot-adaptive-card-actions/csharp/M365Agent/M365Agent.ttkproj
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
- bd0063e4-061d-459c-a143-9805f2a64b99
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/aad.manifest.json b/samples/bot-adaptive-card-actions/csharp/M365Agent/aad.manifest.json
index 74b6608889..7bd8212f10 100644
--- a/samples/bot-adaptive-card-actions/csharp/M365Agent/aad.manifest.json
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/aad.manifest.json
@@ -1,6 +1,6 @@
{
- "id": "${{AAD_APP_OBJECT_ID}}",
- "appId": "${{AAD_APP_CLIENT_ID}}",
+ "id": "${{BOT_OBJECT_ID}}",
+ "appId": "${{BOT_ID}}",
"displayName": "bot-adaptive-card-actions-aad",
"signInAudience": "AzureADMyOrg",
"api": {
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/appPackage/color.png b/samples/bot-adaptive-card-actions/csharp/M365Agent/appPackage/color.png
index b8cf81afbe..01aa37e347 100644
Binary files a/samples/bot-adaptive-card-actions/csharp/M365Agent/appPackage/color.png and b/samples/bot-adaptive-card-actions/csharp/M365Agent/appPackage/color.png differ
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/appPackage/manifest.json b/samples/bot-adaptive-card-actions/csharp/M365Agent/appPackage/manifest.json
index 073256fbbd..13e82a26bf 100644
--- a/samples/bot-adaptive-card-actions/csharp/M365Agent/appPackage/manifest.json
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/appPackage/manifest.json
@@ -1,4 +1,4 @@
-{
+{
"$schema": "https://developer.microsoft.com/json-schemas/teams/v1.22/MicrosoftTeams.schema.json",
"manifestVersion": "1.22",
"version": "1.0.0",
@@ -24,7 +24,7 @@
"accentColor": "#60A18E",
"bots": [
{
- "botId": "${{AAD_APP_CLIENT_ID}}",
+ "botId": "${{BOT_ID}}",
"scopes": [
"personal",
"copilot"
@@ -40,7 +40,7 @@
"customEngineAgents": [
{
"type": "bot",
- "id": "${{AAD_APP_CLIENT_ID}}"
+ "id": "${{BOT_ID}}"
}
]
}
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/appPackage/outline.png b/samples/bot-adaptive-card-actions/csharp/M365Agent/appPackage/outline.png
index 2c3bf6fa65..f7a4c86447 100644
Binary files a/samples/bot-adaptive-card-actions/csharp/M365Agent/appPackage/outline.png and b/samples/bot-adaptive-card-actions/csharp/M365Agent/appPackage/outline.png differ
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/env/.env.dev b/samples/bot-adaptive-card-actions/csharp/M365Agent/env/.env.dev
new file mode 100644
index 0000000000..df4f9da508
--- /dev/null
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/env/.env.dev
@@ -0,0 +1,15 @@
+# This file includes environment variables that will be committed to git by default.
+
+# Built-in environment variables
+TEAMSFX_ENV=dev
+APP_NAME_SUFFIX=dev
+
+# Updating AZURE_SUBSCRIPTION_ID or AZURE_RESOURCE_GROUP_NAME after provision may also require an update to RESOURCE_SUFFIX, because some services require a globally unique name across subscriptions/resource groups.
+AZURE_SUBSCRIPTION_ID=
+AZURE_RESOURCE_GROUP_NAME=
+RESOURCE_SUFFIX=
+
+# Generated during provision, you can also add your own variables.
+BOT_ID=
+TEAMS_APP_ID=
+BOT_AZURE_APP_SERVICE_RESOURCE_ID=
\ No newline at end of file
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/env/.env.local b/samples/bot-adaptive-card-actions/csharp/M365Agent/env/.env.local
index f6296d6224..86dfacc35a 100644
--- a/samples/bot-adaptive-card-actions/csharp/M365Agent/env/.env.local
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/env/.env.local
@@ -7,19 +7,9 @@ APP_NAME_SUFFIX=local
# Generated during provision, you can also add your own variables.
BOT_ID=
TEAMS_APP_ID=
-RESOURCE_SUFFIX=
-AAD_APP_CLIENT_ID=
-AAD_APP_OBJECT_ID=
-AAD_APP_TENANT_ID=
-AAD_APP_OAUTH_AUTHORITY=
-AAD_APP_OAUTH_AUTHORITY_HOST=
TEAMS_APP_TENANT_ID=
-MICROSOFT_APP_TYPE=
-MICROSOFT_APP_TENANT_ID=
+BOT_OBJECT_ID=
TEAMSFX_M365_USER_NAME=
BOT_ENDPOINT=
-BOT_DOMAIN=
-
-AZURE_SUBSCRIPTION_ID=
-AZURE_RESOURCE_GROUP_NAME=
\ No newline at end of file
+BOT_DOMAIN=
\ No newline at end of file
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/azure.bicep b/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/azure.bicep
index c3ce051b3d..658e412a21 100644
--- a/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/azure.bicep
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/azure.bicep
@@ -3,42 +3,84 @@
@description('Used to generate names for all resources in this file')
param resourceBaseName string
-@description('Required when create Azure Bot service')
-param botAadAppClientId string
-
-param botAppDomain string
+param webAppSKU string
@maxLength(42)
param botDisplayName string
-param botServiceName string = resourceBaseName
-param botServiceSku string = 'F0'
-param microsoftAppType string
-param microsoftAppTenantId string
+param serverfarmsName string = resourceBaseName
+param webAppName string = resourceBaseName
+param identityName string = resourceBaseName
+param location string = resourceGroup().location
-// Register your web service as a bot with the Bot Framework
-resource botService 'Microsoft.BotService/botServices@2021-03-01' = {
- kind: 'azurebot'
- location: 'global'
- name: botServiceName
- properties: {
- displayName: botDisplayName
- endpoint: 'https://${botAppDomain}/api/messages'
- msaAppId: botAadAppClientId
- msaAppType: microsoftAppType
- msaAppTenantId: microsoftAppType == 'SingleTenant' ? microsoftAppTenantId : ''
- }
+resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
+ location: location
+ name: identityName
+}
+
+// Compute resources for your Web App
+resource serverfarm 'Microsoft.Web/serverfarms@2021-02-01' = {
+ kind: 'app'
+ location: location
+ name: serverfarmsName
sku: {
- name: botServiceSku
+ name: webAppSKU
}
}
-// Connect the bot service to Microsoft Teams
-resource botServiceMsTeamsChannel 'Microsoft.BotService/botServices/channels@2021-03-01' = {
- parent: botService
- location: 'global'
- name: 'MsTeamsChannel'
+// Web App that hosts your bot
+resource webApp 'Microsoft.Web/sites@2021-02-01' = {
+ kind: 'app'
+ location: location
+ name: webAppName
properties: {
- channelName: 'MsTeamsChannel'
+ serverFarmId: serverfarm.id
+ httpsOnly: true
+ siteConfig: {
+ appSettings: [
+ {
+ name: 'WEBSITE_RUN_FROM_PACKAGE'
+ value: '1'
+ }
+ {
+ name: 'Teams__ClientId'
+ value: identity.properties.clientId
+ }
+ {
+ name: 'Teams__TenantId'
+ value: identity.properties.tenantId
+ }
+ {
+ name: 'Teams__BotType'
+ value: 'UserAssignedMsi'
+ }
+ ]
+ ftpsState: 'FtpsOnly'
+ }
+ }
+ identity: {
+ type: 'UserAssigned'
+ userAssignedIdentities: {
+ '${identity.id}': {}
+ }
+ }
+}
+
+// Register your web service as a bot with the Bot Framework
+module azureBotRegistration './botRegistration/azurebot.bicep' = {
+ name: 'Azure-Bot-registration'
+ params: {
+ resourceBaseName: resourceBaseName
+ identityClientId: identity.properties.clientId
+ identityResourceId: identity.id
+ identityTenantId: identity.properties.tenantId
+ botAppDomain: webApp.properties.defaultHostName
+ botDisplayName: botDisplayName
}
}
+
+// The output will be persisted in .env.{envName}. Visit https://aka.ms/teamsfx-actions/arm-deploy for more details.
+output BOT_AZURE_APP_SERVICE_RESOURCE_ID string = webApp.id
+output BOT_DOMAIN string = webApp.properties.defaultHostName
+output BOT_ID string = identity.properties.clientId
+output BOT_TENANT_ID string = identity.properties.tenantId
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/azure.parameters.json b/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/azure.parameters.json
index d8454ee752..aabb59b8af 100644
--- a/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/azure.parameters.json
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/azure.parameters.json
@@ -1,24 +1,15 @@
{
- "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
- "contentVersion": "1.0.0.0",
- "parameters": {
- "resourceBaseName": {
- "value": "bot${{RESOURCE_SUFFIX}}"
- },
- "botAadAppClientId": {
- "value": "${{AAD_APP_CLIENT_ID}}"
- },
- "botAppDomain": {
- "value": "${{BOT_DOMAIN}}"
- },
- "botDisplayName": {
- "value": "TestBot"
- },
- "microsoftAppType": {
- "value": "${{MICROSOFT_APP_TYPE}}"
- },
- "microsoftAppTenantId": {
- "value": "${{MICROSOFT_APP_TENANT_ID}}"
+ "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
+ "contentVersion": "1.0.0.0",
+ "parameters": {
+ "resourceBaseName": {
+ "value": "bot${{RESOURCE_SUFFIX}}"
+ },
+ "webAppSKU": {
+ "value": "B1"
+ },
+ "botDisplayName": {
+ "value": "AdaptiveCardActions"
+ }
}
- }
-}
\ No newline at end of file
+ }
\ No newline at end of file
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/botRegistration/azurebot.bicep b/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/botRegistration/azurebot.bicep
new file mode 100644
index 0000000000..a5a27b8fe4
--- /dev/null
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/botRegistration/azurebot.bicep
@@ -0,0 +1,42 @@
+@maxLength(20)
+@minLength(4)
+@description('Used to generate names for all resources in this file')
+param resourceBaseName string
+
+@maxLength(42)
+param botDisplayName string
+
+param botServiceName string = resourceBaseName
+param botServiceSku string = 'F0'
+param identityResourceId string
+param identityClientId string
+param identityTenantId string
+param botAppDomain string
+
+// Register your web service as a bot with the Bot Framework
+resource botService 'Microsoft.BotService/botServices@2021-03-01' = {
+ kind: 'azurebot'
+ location: 'global'
+ name: botServiceName
+ properties: {
+ displayName: botDisplayName
+ endpoint: 'https://${botAppDomain}/api/messages'
+ msaAppId: identityClientId
+ msaAppMSIResourceId: identityResourceId
+ msaAppTenantId:identityTenantId
+ msaAppType:'UserAssignedMSI'
+ }
+ sku: {
+ name: botServiceSku
+ }
+}
+
+// Connect the bot service to Microsoft Teams
+resource botServiceMsTeamsChannel 'Microsoft.BotService/botServices/channels@2021-03-01' = {
+ parent: botService
+ location: 'global'
+ name: 'MsTeamsChannel'
+ properties: {
+ channelName: 'MsTeamsChannel'
+ }
+}
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/botRegistration/readme.md b/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/botRegistration/readme.md
new file mode 100644
index 0000000000..d5416243cd
--- /dev/null
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/infra/botRegistration/readme.md
@@ -0,0 +1 @@
+The `azurebot.bicep` module is provided to help you create Azure Bot service when you don't use Azure to host your app. If you use Azure as infrastrcture for your app, `azure.bicep` under infra folder already leverages this module to create Azure Bot service for you. You don't need to deploy `azurebot.bicep` again.
\ No newline at end of file
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/launchSettings.json b/samples/bot-adaptive-card-actions/csharp/M365Agent/launchSettings.json
index d6491ef52c..2af8ce7a8a 100644
--- a/samples/bot-adaptive-card-actions/csharp/M365Agent/launchSettings.json
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/launchSettings.json
@@ -1,15 +1,25 @@
{
- "profiles": {
- // Debug project within Teams
- "Microsoft Teams (browser)": {
- "commandName": "Project",
- "launchUrl": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&appTenantId=${{TEAMS_APP_TENANT_ID}}&login_hint=${{TEAMSFX_M365_USER_NAME}}"
- },
- // Launch project within Teams without prepare app dependencies
- "Microsoft Teams (browser) (skip update app)": {
- "commandName": "Project",
- "environmentVariables": { "UPDATE_TEAMS_APP": "false" },
- "launchUrl": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&appTenantId=${{TEAMS_APP_TENANT_ID}}&login_hint=${{TEAMSFX_M365_USER_NAME}}"
- }
- }
+ "profiles": {
+ // Launch project within Microsoft 365 Agents Playground
+ "Microsoft 365 Agents Playground (browser)": {
+ "commandName": "Project",
+ "environmentVariables": {
+ "UPDATE_TEAMS_APP": "false",
+ "M365_AGENTS_PLAYGROUND_TARGET_SDK": "teams-ai-v2-dotnet"
+ },
+ "launchTestTool": true,
+ "launchUrl": "http://localhost:56150",
+ },
+ // Launch project within Teams
+ "Microsoft Teams (browser)": {
+ "commandName": "Project",
+ "launchUrl": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&appTenantId=${{TEAMS_APP_TENANT_ID}}&login_hint=${{TEAMSFX_M365_USER_NAME}}",
+ },
+ // Launch project within Teams without prepare app dependencies
+ "Microsoft Teams (browser) (skip update app)": {
+ "commandName": "Project",
+ "environmentVariables": { "UPDATE_TEAMS_APP": "false" },
+ "launchUrl": "https://teams.microsoft.com/l/app/${{TEAMS_APP_ID}}?installAppPackage=true&webjoin=true&appTenantId=${{TEAMS_APP_TENANT_ID}}&login_hint=${{TEAMSFX_M365_USER_NAME}}"
+ },
+ }
}
\ No newline at end of file
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/m365agents.local.yml b/samples/bot-adaptive-card-actions/csharp/M365Agent/m365agents.local.yml
index b2934e6f8c..e67997c8fe 100644
--- a/samples/bot-adaptive-card-actions/csharp/M365Agent/m365agents.local.yml
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/m365agents.local.yml
@@ -1,72 +1,66 @@
-# yaml-language-server: $schema=https://aka.ms/teams-toolkit/v1.8/yaml.schema.json
+# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.11/yaml.schema.json
# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file
# Visit https://aka.ms/teamsfx-actions for details on actions
-version: v1.8
-
-additionalMetadata:
- sampleTag: Microsoft-Teams-Samples:bot-adaptive-card-actions-csharp
+version: v1.11
provision:
- - uses: aadApp/create # Creates a new Azure Active Directory (AAD) app to authenticate users if the environment variable that stores clientId is empty
- with:
- name: bot-adaptive-card-actions-aad # Note: when you run aadApp/update, the AAD app name will be updated based on the definition in manifest. If you don't want to change the name, make sure the name in AAD manifest is the same with the name defined here.
- generateClientSecret: true # If the value is false, the action will not generate client secret for you
- signInAudience: "AzureADMultipleOrgs" # Multitenant
- writeToEnvironmentFile:
- # Write the information of created resources into environment file for the specified environment variable(s).
- clientId: AAD_APP_CLIENT_ID
- clientSecret: SECRET_AAD_APP_CLIENT_SECRET # Environment variable that starts with `SECRET_` will be stored to the .env.{envName}.user environment file
- objectId: AAD_APP_OBJECT_ID
- tenantId: AAD_APP_TENANT_ID
- authority: AAD_APP_OAUTH_AUTHORITY
- authorityHost: AAD_APP_OAUTH_AUTHORITY_HOST
-
# Creates a Teams app
- uses: teamsApp/create
with:
# Teams app name
- name: bot-adaptive-card-actions${{APP_NAME_SUFFIX}}
+ name: AdaptiveCardActions${{APP_NAME_SUFFIX}}
# Write the information of created resources into environment file for
# the specified environment variable(s).
writeToEnvironmentFile:
teamsAppId: TEAMS_APP_ID
- - uses: script
+ # Create or reuse an existing Microsoft Entra application for bot.
+ - uses: aadApp/create
+ with:
+ # The Microsoft Entra application's display name
+ name: AdaptiveCardActions${{APP_NAME_SUFFIX}}
+ generateClientSecret: true
+ generateServicePrincipal: true
+ signInAudience: AzureADMultipleOrgs
+ writeToEnvironmentFile:
+ # The Microsoft Entra application's client id created for bot.
+ clientId: BOT_ID
+ # The Microsoft Entra application's client secret created for bot.
+ clientSecret: SECRET_BOT_PASSWORD
+ # The Microsoft Entra application's object id created for bot.
+ objectId: BOT_OBJECT_ID
+
+ # Update Microsoft Entra app with aad.manifest.json
+ - uses: aadApp/update
with:
- run: echo "::set-teamsfx-env MICROSOFT_APP_TYPE=SingleTenant"; echo
- "::set-teamsfx-env MICROSOFT_APP_TENANT_ID=${{AAD_APP_TENANT_ID}}";
+ manifestPath: ./aad.manifest.json
+ outputFilePath: ./build/aad.manifest.${{TEAMSFX_ENV}}.json
# Generate runtime appsettings to JSON file
- uses: file/createOrUpdateJsonFile
with:
- target: ../AdaptiveCardActions/appsettings.json
+ target: ../AdaptiveCardActions/appsettings.Development.json
content:
- MicrosoftAppId: ${{AAD_APP_CLIENT_ID}}
- MicrosoftAppPassword: ${{SECRET_AAD_APP_CLIENT_SECRET}}
- MicrosoftAppType: ${{MICROSOFT_APP_TYPE}}
- MicrosoftAppTenantId: ${{MICROSOFT_APP_TENANT_ID}}
-
- - uses: arm/deploy # Deploy given ARM templates parallelly.
- with:
- subscriptionId: ${{AZURE_SUBSCRIPTION_ID}} # The AZURE_SUBSCRIPTION_ID is a built-in environment variable. TeamsFx will ask you select one subscription if its value is empty. You're free to reference other environment varialbe here, but TeamsFx will not ask you to select subscription if it's empty in this case.
- resourceGroupName: ${{AZURE_RESOURCE_GROUP_NAME}} # The AZURE_RESOURCE_GROUP_NAME is a built-in environment variable. TeamsFx will ask you to select or create one resource group if its value is empty. You're free to reference other environment varialbe here, but TeamsFx will not ask you to select or create resource grouop if it's empty in this case.
- templates:
- - path: ./infra/azure.bicep
- parameters: ./infra/azure.parameters.json
- deploymentName: Create-resources-for-bot
- bicepCliVersion: v0.9.1 # Microsoft 365 Agents Toolkit will download this bicep CLI version from github for you, will use bicep CLI in PATH if you remove this config.
+ Teams:
+ ClientId: ${{BOT_ID}}
+ ClientSecret: ${{SECRET_BOT_PASSWORD}}
+ TenantId: ${{TEAMS_APP_TENANT_ID}}
- - uses: aadApp/update # Apply the AAD manifest to an existing AAD app. Will use the object id in manifest file to determine which AAD app to update.
+ # Create or update the bot registration on dev.botframework.com
+ - uses: botFramework/create
with:
- manifestPath: ./aad.manifest.json # Relative path to teamsfx folder. Environment variables in manifest will be replaced before apply to AAD app
- outputFilePath: ./build/aad.manifest.${{TEAMSFX_ENV}}.json
+ botId: ${{BOT_ID}}
+ name: AdaptiveCardActions
+ messagingEndpoint: ${{BOT_ENDPOINT}}/api/messages
+ description: ""
+ channels:
+ - name: msteams
# Validate using manifest schema
- uses: teamsApp/validateManifest
with:
# Path to manifest template
manifestPath: ./appPackage/manifest.json
-
# Build Teams app package with latest env value
- uses: teamsApp/zipAppPackage
with:
diff --git a/samples/bot-adaptive-card-actions/csharp/M365Agent/m365agents.yml b/samples/bot-adaptive-card-actions/csharp/M365Agent/m365agents.yml
index 93004d9346..6349e99e3d 100644
--- a/samples/bot-adaptive-card-actions/csharp/M365Agent/m365agents.yml
+++ b/samples/bot-adaptive-card-actions/csharp/M365Agent/m365agents.yml
@@ -1,9 +1,88 @@
-# yaml-language-server: $schema=https://aka.ms/teams-toolkit/v1.8/yaml.schema.json
+# yaml-language-server: $schema=https://aka.ms/m365-agents-toolkits/v1.9/yaml.schema.json
# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file
# Visit https://aka.ms/teamsfx-actions for details on actions
-version: v1.8
+version: v1.9
-additionalMetadata:
- sampleTag: Microsoft-Teams-Samples:bot-adaptive-card-actions-csharp
+environmentFolderPath: ./env
-environmentFolderPath: ./env
\ No newline at end of file
+# Triggered when 'teamsapp provision' is executed
+provision:
+ # Creates a Teams app
+ - uses: teamsApp/create
+ with:
+ # Teams app name
+ name: AdaptiveCardActions${{APP_NAME_SUFFIX}}
+ # Write the information of created resources into environment file for
+ # the specified environment variable(s).
+ writeToEnvironmentFile:
+ teamsAppId: TEAMS_APP_ID
+
+ - uses: arm/deploy # Deploy given ARM templates parallelly.
+ with:
+ # AZURE_SUBSCRIPTION_ID is a built-in environment variable,
+ # if its value is empty, TeamsFx will prompt you to select a subscription.
+ # Referencing other environment variables with empty values
+ # will skip the subscription selection prompt.
+ subscriptionId: ${{AZURE_SUBSCRIPTION_ID}}
+ # AZURE_RESOURCE_GROUP_NAME is a built-in environment variable,
+ # if its value is empty, TeamsFx will prompt you to select or create one
+ # resource group.
+ # Referencing other environment variables with empty values
+ # will skip the resource group selection prompt.
+ resourceGroupName: ${{AZURE_RESOURCE_GROUP_NAME}}
+ templates:
+ - path: ./infra/azure.bicep # Relative path to this file
+ # Relative path to this yaml file.
+ # Placeholders will be replaced with corresponding environment
+ # variable before ARM deployment.
+ parameters: ./infra/azure.parameters.json
+ # Required when deploying ARM template
+ deploymentName: Create-resources-for-bot
+ # Microsoft 365 Agents Toolkit will download this bicep CLI version from github for you,
+ # will use bicep CLI in PATH if you remove this config.
+ bicepCliVersion: v0.9.1
+
+ # Validate using manifest schema
+ - uses: teamsApp/validateManifest
+ with:
+ # Path to manifest template
+ manifestPath: ./appPackage/manifest.json
+ # Build Teams app package with latest env value
+ - uses: teamsApp/zipAppPackage
+ with:
+ # Path to manifest template
+ manifestPath: ./appPackage/manifest.json
+ outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
+ outputFolder: ./appPackage/build
+ # Validate app package using validation rules
+ - uses: teamsApp/validateAppPackage
+ with:
+ # Relative path to this file. This is the path for built zip file.
+ appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
+ # Apply the Teams app manifest to an existing Teams app in
+ # Developer Portal.
+ # Will use the app id in manifest file to determine which Teams app to update.
+ - uses: teamsApp/update
+ with:
+ # Relative path to this file. This is the path for built zip file.
+ appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
+
+# Triggered when 'teamsapp deploy' is executed
+deploy:
+ - uses: cli/runDotnetCommand
+ with:
+ args: publish --configuration Release --runtime win-x86 --self-contained
+ AdaptiveCardActions.csproj
+ workingDirectory: ../AdaptiveCardActions
+ # Deploy your application to Azure App Service using the zip deploy feature.
+ # For additional details, refer to https://aka.ms/zip-deploy-to-app-services.
+ - uses: azureAppService/zipDeploy
+ with:
+ # Deploy base folder
+ artifactFolder: bin/Release/net10.0/win-x86/publish
+ # The resource id of the cloud resource to be deployed to.
+ # This key will be generated by arm/deploy action automatically.
+ # You can replace it with your existing Azure Resource id
+ # or add it to your environment variable file.
+ resourceId: ${{BOT_AZURE_APP_SERVICE_RESOURCE_ID}}
+ workingDirectory: ../AdaptiveCardActions
diff --git a/samples/bot-adaptive-card-actions/csharp/README.md b/samples/bot-adaptive-card-actions/csharp/README.md
index 25a5598ded..199942b6e1 100644
--- a/samples/bot-adaptive-card-actions/csharp/README.md
+++ b/samples/bot-adaptive-card-actions/csharp/README.md
@@ -64,16 +64,18 @@ The simplest way to run this sample in Teams is to use Microsoft 365 Agents Tool
> NOTE: When you create your app registration, you will create an App ID and App password - make sure you keep these for later.
-2. Run ngrok - point to port 3978
+2. Setup dev tunnel - point to port 3978
+
+ Please follow [Create and host a dev tunnel](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started?tabs=windows) and host the tunnel with anonymous user access command as shown below:
```bash
- ngrok http 3978 --host-header="localhost:3978"
- ```
+ devtunnel host -p 3978 --allow-anonymous
+ ```
- Alternatively, you can also use the `dev tunnels`. Please follow [Create and host a dev tunnel](https://learn.microsoft.com/en-us/azure/developer/dev-tunnels/get-started?tabs=windows) and host the tunnel with anonymous user access command as shown below:
+ Alternatively, you can also use ngrok:
```bash
- devtunnel host -p 3978 --allow-anonymous
+ ngrok http 3978 --host-header="localhost:3978"
```
3. Register a new application in the [Microsoft Entra ID – App Registrations](https://go.microsoft.com/fwlink/?linkid=2083908) portal.
@@ -83,13 +85,14 @@ The simplest way to run this sample in Teams is to use Microsoft 365 Agents Tool
* Choose the **supported account types** (any account type will work)
* Leave **Redirect URI** empty.
* Choose **Register**.
- B) On the overview page, copy and save the **Application (client) ID, Directory (tenant) ID**. You'll need those later when updating your Teams application manifest and in the appsettings.json.
+ B) On the overview page, copy and save the **Application (client) ID, Directory (tenant) ID**. You'll need those later when updating in the appsettings.Development.json.
C) Navigate to **API Permissions**, and make sure to add the follow permissions:
Select Add a permission
* Select Add a permission
* Select Microsoft Graph -\> Delegated permissions.
* `User.Read` (enabled by default)
* Click on Add permissions. Please make sure to grant the admin consent for the required permissions.
+ D) Under **Certificates & secrets**, create a new **Client secret** and save the value. You'll need this for the `ClientSecret` in appsettings.Development.json.
4. Setup For Code
@@ -104,16 +107,19 @@ The simplest way to run this sample in Teams is to use Microsoft 365 Agents Tool
- Launch Visual Studio
- File -> Open Folder
- Navigate to `samples/bot-adaptive-card-actions/csharp/AdaptiveCardActions` folder
- - Select `AdaptiveCardActions.sln` solution file
-
- - Modify the `/appsettings.json` and fill in the following details:
- - `{{MicrosoftAppId}}` - Generated from Step 1 is the application app id
- - `{{MicrosoftAppPassword}}` - Generated from Step 1, also referred to as Client secret
+ - Select `AdaptiveCardActions.slnx` solution file
+
+ - Create your local `launchSettings.json` file in the `AdaptiveCardActions/Properties` folder. This file configures how Visual Studio launches and debugs your application, including environment variables and application URLs. Use `launchSettings.example.json` as a template to create your own configuration.
+
+ - Modify the `/appsettings.Development.json` and fill in the following details:
+ - `ClientId` - Generated from Step 1 is the application app id
+ - `ClientSecret` - Generated from Step 1, also referred to as Client secret
+ - `TenantId` - Your Microsoft 365 tenant ID from Step 3
- Press `F5` to run the project
5. Setup Manifest for Teams
- __*This step is specific to Teams.*__
- - **Edit** the `manifest.json` contained in the ./appPackage folder to replace your Microsoft App Id (that was created when you registered your app registration earlier) *everywhere* you see the place holder string `{{Microsoft-App-Id}}` (depending on the scenario the Microsoft App Id may occur multiple times in the `manifest.json`)
+ - **Edit** the `manifest.json` contained in the ./appPackage folder to replace your Microsoft App Id (that was created when you registered your app registration earlier) *everywhere* you see the place holder string `{{TEAMS_APP_ID}} and {{BOT_ID}}` (depending on the scenario the Microsoft App Id may occur multiple times in the `manifest.json`)
- **Edit** the `manifest.json` for `validDomains` and replace `{{Domain-Name}}` with base Url of your domain. E.g. if you are using ngrok it would be `https://1234.ngrok-free.app` then your domain-name will be `1234.ngrok-free.app` and if you are using dev tunnels then your domain will be like: `12345.devtunnels.ms`.
- **Zip** up the contents of the `appPackage` folder to create a `manifest.zip` (Make sure that zip file does not contains any subfolder otherwise you will get error while uploading your .zip package)
@@ -123,8 +129,6 @@ The simplest way to run this sample in Teams is to use Microsoft 365 Agents Tool
- Go to your project directory, the ./appPackage folder, select the zip folder, and choose Open.
- Select Add in the pop-up dialog box. Your app is uploaded to Teams.
-**Note**: If you are facing any issue in your app, please uncomment [this](https://github.com/OfficeDev/Microsoft-Teams-Samples/blob/main/samples/bot-adaptive-card-actions/csharp/AdaptiveCardActions/AdapterWithErrorHandler.cs#L28) line and put your debugger for local debug.
-
## Running the sample
diff --git a/samples/bot-adaptive-card-actions/csharp/assets/sample.json b/samples/bot-adaptive-card-actions/csharp/assets/sample.json
index cdb3fa6354..0b2ee72946 100644
--- a/samples/bot-adaptive-card-actions/csharp/assets/sample.json
+++ b/samples/bot-adaptive-card-actions/csharp/assets/sample.json
@@ -9,7 +9,7 @@
"This sample demonstrates how to create and send Adaptive Cards with different action types using a Microsoft Teams bot. It includes features like submitting actions, showing cards, toggling visibility, and more."
],
"creationDateTime": "2022-12-27",
- "updateDateTime": "2024-10-10",
+ "updateDateTime": "2025-10-12",
"products": [
"Teams"
],