重要
Microsoft 365 Agents Toolkit は Teams エージェントおよびアプリ開発では非推奨となり、TeamsFx SDK はすべてのシナリオで完全に非推奨となりました。
すべての新しい Teams エージェントとアプリの開発には、 Teams SDK と Teams 開発者 CLI を使用します。
TeamsFx は Azure および Microsoft 365 クラウドと統合されているため、1 つのコマンドでアプリを Azure に配置できます。 TeamsFx は Azure Resource Manager (ARM) と統合されているため、アプリケーションがコード アプローチに必要な Azure リソースをプロビジョニングできます。
Visual Studio Code で Microsoft 365 Agents Toolkit を使用してプロビジョニングする
Agents Toolkit (旧称 Teams Toolkit) または Microsoft 365 Agents Toolkit CLI (旧称 TeamsFx CLI) でプロビジョニング コマンドをトリガーして、アプリケーションのリソースを作成または更新できます。 プロビジョニング コマンドの手順は、 m365agents.yml ファイルの provision プロパティで定義されています。 ファイルを表示して、作成されるリソースを確認できます。
注
Azure サービスでは、サブスクリプションにコストが発生します。 コスト見積もりの詳細については、「 料金計算ツール」を参照してください。
プロビジョニング アクション
次の一覧は、プロビジョニング用に設計されたアクションを示しています。
teamsApp/create
説明
Teams アプリ ID を格納する環境変数が空の場合、またはアプリ ID が Teams 開発者ポータルから見つからない場合は、このアクションにより新しい Teams アプリが作成されます。
運用されるリソースの種類
Teams 開発者ポータルの Teams アプリ。
使用方法
- uses: teamsApp/create
with:
# #required. Name of Teams app
name: <your-preferred-app-name>
# Write the information of created resources into environment file for the specified environment variable(s).
writeToEnvironmentFile:
# The id for Teams app
teamsAppId: <your-preferred-env-var-name>
teamsApp/update
説明
Teams 開発者ポータルで、アプリ マニフェスト (以前は Teams アプリ マニフェスト) を既存の Teams アプリに適用します。
manifest.json ファイル内のアプリ ID を使用して、更新する Teams アプリを決定します。
運用されるリソースの種類
Teams 開発者ポータルの Teams アプリ。
使用方法
- uses: teamsApp/update
with:
# Required. Relative path to the yaml file. This is the path for built zip file.
appPackagePath: <path-to-teams-app-package-file>
teamsApp/validateManifest
説明
このアクションにより、環境変数を含むアプリ マニフェスト テンプレートがレンダリングされ、そのスキーマを使用してアプリ マニフェスト ファイルが検証されます。
運用されるリソースの種類
該当なし
使用方法
- uses: teamsApp/validate
with:
# Required. Relative path to the yaml file. Path to app manifest file
manifestPath: <path-to-manifest-file>
teamsApp/validateAppPackage
説明
このアクションでは、入力規則を使用して Teams アプリ パッケージが検証されます。
運用されるリソースの種類
該当なし
使用方法
- uses: teamsApp/validateAppPackage
with:
# Required. Relative path to the yaml file. This is the path for built zip file.
appPackagePath: <path-to-teams-app-package-file>
teamsApp/zipAppPackage
説明
この操作により、環境変数を含むアプリ マニフェスト テンプレートがレンダリングされ、2 つのアイコンが含まれるアプリ マニフェスト ファイルが zip ファイルに圧縮されます。
運用されるリソースの種類
該当なし
使用方法
- uses: teamsApp/zipAppPackage
with:
# Required. Relative path to the yaml file. This is the path for app manifest file. Environment variables in manifest will be replaced before apply to Microsoft Entra app.
manifestPath: <path-to-manifest-file>
# Required. Relative path to the yaml file. This is the path for built zip file.
outputZipPath: <path-to-generated-zip-file>
# Required. Relative path to the yaml file. This is the path for built manifest json file.
outputJsonPath: <path-to-generated-json-file>
teamsApp/publishAppPackage
説明
このアクションにより、ビルドされた Teams アプリの zip ファイルがテナント アプリ カタログに発行されます。
運用されるリソースの種類
Microsoft 365 テナント アプリ カタログの Teams アプリ。
使用方法
- uses: teamsApp/publishAppPackage
with:
# Required. Relative path to this file. This is the path for built zip file.
appPackagePath: <path-to-teams-app-package>
# Write the information of created resources into environment file for the specified environment variable(s).
writeToEnvironmentFile:
# The Teams app id in tenant app catalog.
publishedAppId: <your-preferred-env-var-name>
aadApp/create
説明
このアクションでは、 clientId を格納する環境変数が空の場合に、ユーザーを認証するための新しい Microsoft Entra アプリケーションが作成されます。
運用されるリソースの種類
Microsoft 365 テナント内の Microsoft Entra ID。
使用方法
- uses: aadApp/create
with:
# Required. The Microsoft Entra app's display name. When you run aadApp/update, the Microsoft Entra 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 Microsoft Entra app manifest is the same with the name defined here.
name: <your-application-name>
# Required. If the value is false, the action will not generate client secret for you
generateClientSecret: true
# Required. Specifies what Microsoft accounts are supported for the current application. Supported values are: `AzureADMyOrg`, `AzureADMultipleOrgs`, `AzureADandPersonalMicrosoftAccount`, `PersonalMicrosoftAccount`.
signInAudience: "AzureADMyOrg"
# Write the information of created resources into environment file for the specified environment variable(s).
writeToEnvironmentFile:
# Required. The client (application) ID of Microsoft Entra application. The action will refer the environment variable defined here to determine whether to create a new Microsoft Entra app.
clientId: <your-preferred-env-var-name>
# Required when `generateClientSecret` is `true`. The action will refer the environment variable defined here to determine whether to create a new client secret. It's recommended to add `SECRET_` prefix to the environment variable name so it will be stored to the .env.{envName}.user environment file.
clientSecret: <your-preferred-env-var-name>
# Required. The object ID of Microsoft Entra application
objectId: <your-preferred-env-var-name>
# Optional. The tenant ID of Microsoft Entra tenant
tenantId: <your-preferred-env-var-name>
# Optional. The Microsoft Entra authority
authority: <your-preferred-env-var-name>
# Optional. The host name of Microsoft Entra authority
authorityHost: <your-preferred-env-var-name>
aadApp/update
説明
このアクションにより、指定された Microsoft Entra アプリ マニフェストに基づいて Microsoft Entra アプリケーションが更新されます。 これは、Microsoft Entra アプリ マニフェストの ID プロパティを参照して、更新する Microsoft Entra アプリを決定します。
運用されるリソースの種類
Microsoft 365 テナント内の Microsoft Entra ID。
使用方法
- uses: aadApp/update
with:
# Required. Relative path to the yaml file. Path to the Microsoft Entra app manifest. Environment variables in manifest will be replaced before apply to Microsoft Entra app.
manifestPath: <path-to-manifest-file>
# Required. Relative path to the yaml folder. This action will output the final Microsoft Entra app manifest used to update Microsoft Entra app to this path.
outputFilePath : <path-to-output-file>
botAadApp/create
説明
このアクションでは、ボット用の新しい Microsoft Entra アプリケーションを作成するか、既存の Microsoft Entra アプリケーションを再利用します。
運用されるリソースの種類
Microsoft 365 テナント内の Microsoft Entra ID。
使用方法
- uses: botAadApp/create
with:
# Required. The Microsoft Entra app's display name
name: <your-app-name>
writeToEnvironmentFile:
# The Microsoft Entra app's client id created for bot.
botId: <your-preferred-env-var-name>
# The Microsoft Entra app's client secret created for bot.
botPassword: <your-preferred-env-var-name>
ARM/DEPLOY
説明
このアクションでは、指定された ARM テンプレートが並列に配置されます。
運用されるリソースの種類
選択します。
使用方法
- uses: arm/deploy
with:
# Required. You can use built-in environment variable `AZURE_SUBSCRIPTION_ID` here. TeamsFx will ask you select one subscription if its value is empty. You're free to reference other environment variable here, but TeamsFx will not ask you to select subscription if it's empty in this case.
subscriptionId: ${{AZURE_SUBSCRIPTION_ID}}
# Required. You can use built-in environment variable `AZURE_RESOURCE_GROUP_NAME` here. TeamsFx will ask you to select or create one resource group if its value is empty. You're free to reference other environment variable here, but TeamsFx will not ask you to select or create resource group if it's empty in this case.
resourceGroupName: ${{AZURE_RESOURCE_GROUP_NAME}}
# Required. The ARM templates to be deployed.
templates:
# Required. Relative path to the yaml file.
- path: <path-to-arm-template>
# Optional. Relative path to the yaml file. TeamsFx will replace the environment variable reference with real value before deploy ARM template.
parameters: <path-to-arm-template-parameter>
# Required. Name of the ARM template deployment.
deploymentName: <arm-deployment-name>
# Optional. 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
azureStorage/enableStaticWebsite
説明
このアクションにより、Azure Storage で静的な Web サイト設定が有効になります。
運用されるリソースの種類
Azure Storage.
使用方法
- uses: azureStorage/enableStaticWebsite
with:
# Required. The resource id of Azure Storage
storageResourceId: ${{<env-name-of-azure-storage-resource-id>}}
# Required. The path to index page.
indexPage: <path-to-index-page>
# Required. The path to error page.
errorPage: <path-to-error-page>
azureStaticWebApps/getDeploymentToken
説明
このアクションにより、Azure Static Web Apps からデプロイ トークンが取得されます。
バージョン情報
v1.4
運用されるリソースの種類
Azure Static Web Apps.
使用方法
- uses: azureStaticWebApps/getDeploymentToken
with:
resourceId: ${{AZURE_STATIC_WEB_APPS_RESOURCE_ID}}
writeToEnvironmentFile:
deploymentToken: SECRET_TAB_SWA_DEPLOYMENT_TOKEN
script
説明
このアクションにより、ユーザー定義のスクリプトが実行されます。
運用されるリソースの種類
該当なし
使用方法
- uses: script
with:
# Required. Command to run or path to the script. Succeeds if exit code is 0. '::set-teamsfx-env key=value' is a special command to generate output variables into .env file, in this case, "mykey=abc" will be added the output in the corresponding .env file.
run: $my_key="abc"; echo "::set-teamsfx-env mykey=${my_key}"
# Optional. Available values are: bash, sh, powershell(Powershell Desktop), pwsh(powershell core), cmd. If omitted, it defaults to bash on Linux/MacOS, defaults to pwsh on windows.
shell: <shell-name>
# Optional. Current working directory. Defaults to the directory of this file.
workingDirectory: <working-directory>
# Optional. Timeout in ms.
timeout: <timeout-in-ms>
# Optional. Redirect stdout and stderr to a file.
redirectTo: <path-to-output-file>
リソース プロビジョニングのカスタマイズ
プロビジョニング手順は、 m365agents.yml ファイルの provision プロパティで定義されています。
provision プロパティにアクションを追加、削除、または更新して、プロビジョニング中に実行する予期されるアクションを定義できます。
パラメーター ファイルでの環境変数の参照
Agents Toolkit では、 m365agents.yml、アプリ マニフェスト、Microsoft Entra アプリ マニフェスト、Azure パラメーター ファイルの環境変数からの値の参照がサポートされています。 構文 ${{ENV_VARIABLE_NAME}} を使用して環境変数を参照できます。
次の例では、環境変数 MY_AZURE_SUBSCRIPTION_ID の値を subscriptionId に設定します。
subscriptionId: ${{MY_AZURE_SUBSCRIPTION_ID}}
ARM テンプレート ファイルのカスタマイズ
定義済みのテンプレートがアプリの要件を満たしていない場合は、独自の ARM テンプレートを作成するか、既存の ARM テンプレートを更新して、次のテンプレートのように arm/deploy アクションへのパスを指定できます。
- uses: arm/deploy
with:
subscriptionId: ${{AZURE_SUBSCRIPTION_ID}}
resourceGroupName: ${{AZURE_RESOURCE_GROUP_NAME}}
templates:
- path: <path-to-your-arm-template>
parameters: <path-to-your-parameter-file>
deploymentName: <arm-deployment-name>
bicepCliVersion: <bicep-cli-version>
arm/deployアクションは、bicep および json 形式で記述された ARM テンプレートをサポートします。 json 形式を使用する場合は、 bicepCliVersion パラメーターを省略できます。 Azure Resource Manager の基本的な知識が必要です。 Azure Resource Manager の使用を開始するには 、Azure Resource Manager のドキュメントを参照してください。
Teams アプリをカスタマイズする
自分で作成した Microsoft Entra アプリを使用する環境変数を追加して、ボットまたは Teams アプリをカスタマイズできます。 Teams アプリをカスタマイズする方法は次のとおりです。
Teams アプリに既存の Microsoft Entra アプリを使用する
手順に従って環境変数を .env ファイルに追加して、Teams アプリ用に作成された Microsoft Entra アプリを使用できます。 Microsoft Entra アプリをまだ持っていない場合、または既に持っているが正しい値を見つける場所がわからない場合は、「 TeamsFx プロジェクトで既存の Microsoft Entra アプリを使用する方法」を参照してください。
m365agents.ymlを開き、aadApp/createアクションを見つけます。writeToEnvironmentFileプロパティで Microsoft Entra アプリの情報を格納する環境変数名を見つけます。 Agents Toolkit を使用してプロジェクトを作成する場合のデフォルトのwriteToenvironmentFile定義は次のとおりです。writeToEnvironmentFile: clientId: AAD_APP_CLIENT_ID clientSecret: SECRET_AAD_APP_CLIENT_SECRET objectId: AAD_APP_OBJECT_ID tenantId: AAD_APP_TENANT_ID authority: AAD_APP_OAUTH_AUTHORITY authorityHost: AAD_APP_OAUTH_AUTHORITY_HOST手順 2 の各環境変数の値を追加します。
次の環境変数とその値を
env\.env.{env}ファイルに追加します。AAD_APP_CLIENT_ID=<value of Microsoft Entra application's client id (application id)> # example: 00000000-0000-0000-0000-000000000000 AAD_APP_OBJECT_ID=<value of Microsoft Entra application's object id> # example: 00000000-0000-0000-0000-000000000000 AAD_APP_TENANT_ID=<value of Microsoft Entra's tenant id>> # example: 00000000-0000-0000-0000-000000000000 AAD_APP_OAUTH_AUTHORITY=<value of Microsoft Entra's authority> # example: https://login.microsoftonline.com/<Directory (tenant) ID> AAD_APP_OAUTH_AUTHORITY_HOST=<host of Microsoft Entra's authority> # example: https://login.microsoftonline.com AAD_APP_ACCESS_AS_USER_PERMISSION_ID=<id of access_as_user permission> # example: 00000000-0000-0000-0000-000000000000アプリケーションに Microsoft Entra アプリ クライアント シークレットが必要な場合は、次の環境変数とその値をファイルに追加
env\.env.{env}.user。SECRET_AAD_APP_CLIENT_SECRET=<value of Microsoft Entra application's client secret>
注
-
writeToEnvironmentFileで異なる名前を使用している場合は、例の環境変数名を忘れずに更新してください。 -
aadApp/createアクションを使用して Microsoft Entra アプリケーションを作成しない場合は、上記の手順を実行せずに、必要な環境変数を希望の名前で追加できます。 - 複数の環境で同じ Microsoft Entra アプリを共有しないようにしてください。
既存の Microsoft Entra アプリをボットに使用する
手順に従って環境変数を .env ファイルに追加して、Teams アプリ用に作成された Microsoft Entra アプリを使用できます。 ボット用の Microsoft Entra アプリがまだない場合、または既にアプリがあるが正しい値を見つける場所がわからない場合は、「 TeamsFx プロジェクトで既存の Microsoft Entra アプリを使用する」を参照してください。
m365agents.ymlを開き、botAadApp/createアクションを見つけます。writeToEnvironmentFileプロパティで Microsoft Entra アプリの情報を格納する環境変数名を見つけます。 Agents Toolkit を使用してプロジェクトを作成する場合のデフォルトのwriteToEnvironmentFile定義は次のとおりです。writeToEnvironmentFile: botId: BOT_ID botPassword: SECRET_BOT_PASSWORD手順 2 の各環境変数の値を追加します。
次の環境変数とその値を
env\.env.{env}ファイルに追加します。BOT_ID=<value of Microsoft Entra application's client id (application id)> # example: 00000000-0000-0000-0000-000000000000次の環境変数とその値を
env\.env.{env}.userファイルに追加します。SECRET_BOT_PASSWORD=<value of Microsoft Entra application's client secret>
注
-
writeToEnvironmentFileで異なる名前を使用している場合は、例の環境変数名を忘れずに更新してください。 -
botAadApp/createアクションを使用して Microsoft Entra アプリケーションを作成しない場合は、上記の手順を実行せずに、必要な環境変数を希望の名前で追加できます。 - 複数の環境で同じ Microsoft Entra アプリを共有しないようにしてください。