> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cloud.cdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Microsoft Power Apps

> OpenAPI 仕様または仮想SQL Server API を使用して、Microsoft Power Apps をConnect AI に接続できます。

## OpenAPI 経由で接続するための前提条件

OpenAPI 経由で接続する前に、まず以下を実行します。

* データソースをConnect AI アカウントに接続します。詳しくは、[Sources](/ja/Sources) を参照してください。
* ワークスペースに[ワークスペースを追加](/ja/Workspaces#ワークスペースを追加)します。
* ワークスペースに[アセットを追加](/ja/Workspaces#ワークスペースのアセット)します。
* [Settings](/ja/Settings#personal-access-tokens) ページでPersonal Access Token (PAT) を生成します。PAT をコピーし、認証時にパスワードとして使用します。

## OpenAPI 経由で接続

OpenAPI 経由でMicrosoft Power Apps からConnect AI へのコネクションを確立するには、以下の手順に従います。

<Steps>
  <Step>
    Connect AI の**Workspaces** で、ワークスペースを選択し、そのワークスペースの OpenAPI 仕様をダウンロードします。詳しくは、[OpenAPI](/ja/API/OpenAPI) を参照してください。

    <Note>
      OpenAPI バージョン2.0 を使用し、**Convert array types to strings** を選択する必要があります。
    </Note>

    <Frame>
      <img src="https://mintcdn.com/cdata/DDl5yMaSE1cK608F/ja/images/powerautomate_client_endpoints.png?fit=max&auto=format&n=DDl5yMaSE1cK608F&q=85&s=652615f82301983a4b122d67b16d11d5" alt="" width="750" height="533" data-path="ja/images/powerautomate_client_endpoints.png" />
    </Frame>
  </Step>

  <Step>
    Microsoft Power Apps にログインします。
  </Step>

  <Step>
    **Custom connectors** を選択してカスタムコネクタを作成します（**Custom connectors** を見つけるには、**Discover all** をクリックする必要がある場合があります）。
  </Step>

  <Step>
    Select **New custom connector** > **Import an OpenAPI file**.

    <Frame>
      <img src="https://mintcdn.com/cdata/DDl5yMaSE1cK608F/ja/images/powerapps_importopenAPI.png?fit=max&auto=format&n=DDl5yMaSE1cK608F&q=85&s=834570a645ddc9fe6ef23ad9171f6afa" alt="" width="387" height="387" data-path="ja/images/powerapps_importopenAPI.png" />
    </Frame>
  </Step>

  <Step>
    Enter a **Connector name** and import the OpenAPI specification file you downloaded.
  </Step>

  <Step>
    In the **1. General** step, enter general information about the connector, including a description. **Host** and **Base URL** are required, but are already filled in.
  </Step>

  <Step>
    In the **2. Security** step, select an **Authentication type** of **Basic authentication**. Users have to provide a user name and password before using this API. Enter the parameter labels that users will see.

    <Note>
      When you use the custom connector, the user name is the Connect AI user name, and the password is the PAT created in the prerequisites.
    </Note>
  </Step>

  <Step>
    The **3. Definition** step of the connector defines all the actions of the connector that are contained in the OpenAPI specification file. The actions include all the functions you need for the table, including list, get, create, update, and delete records.
    In the **3. Definition** step, you can edit the **Actions**, **References**, and **Policies** imported from the OpenAPI specification.

    * **Actions**—each action in the custom connector has **General** information, as well as the **Request**, **Response**, and **Validation** of the response.
      For example, the following request is a GET request to list drives.

    <Frame>
      <img src="https://mintcdn.com/cdata/DDl5yMaSE1cK608F/ja/images/powerapps_request.png?fit=max&auto=format&n=DDl5yMaSE1cK608F&q=85&s=b7a2b745051a9babf721b8fdf65402d8" alt="" width="686" height="851" data-path="ja/images/powerapps_request.png" />
    </Frame>

    The request includes query parameters that are appended to the URL, such as `$top`, `$filter`, and `$orderby`. You can edit and delete the query parameters here. The parameters are based on the OData protocol.
    See [API Operations](/ja/API/OpenAPI#api-operations) for a complete reference.
    The **Test** step of creating a custom connector is where you can test out the query parameters.
    Similarly, there is a POST request to create a new record. The request contains all the fields for the record. You can edit these fields in the definition.

    * **References**—reusable parameters that are used by both actions and triggers. Each reference has a **Definition** and **Validation**.
    * **Policies**—used to change the behavior of actions through configuration.
  </Step>

  <Step>
    Save the custom connector.
  </Step>

  <Step>
    In the **6. Test** step, you can test the behavior of each operation defined in the OpenAPI specification by applying query parameters.
    For example, you can test the `$top` and `$orderby` query parameters by returning the top 100 records, ordered by `name`.

    <Frame>
      <img src="https://mintcdn.com/cdata/DDl5yMaSE1cK608F/ja/images/powerapps_test.png?fit=max&auto=format&n=DDl5yMaSE1cK608F&q=85&s=5417e8d131d85f83c3b91edf1f7983ba" alt="Power Apps test" width="674" height="513" data-path="ja/images/powerapps_test.png" />
    </Frame>
  </Step>

  <Step>
    You can now build apps with your custom connector.
  </Step>
</Steps>

## 仮想SQL Server API 経由で接続するための前提条件

仮想SQL Server API 経由で接続する前に、まず以下を実行します。

* データソースをConnect AI アカウントに接続します。詳しくは、[Sources](/ja/Sources) を参照してください。
* Connect AI ワークスペースに接続する場合は、Workspaces に[ワークスペースを追加](/ja/Workspaces)して、自分のワークスペースに[アセットを追加](/ja/Workspaces)します。
* [Settings](/ja/Settings#personal-access-tokens) ページでPersonal Access Token (PAT) を生成します。PAT をコピーし、認証時にパスワードとして使用します。

## 仮想SQL Server API 経由で接続

Microsoft Power Apps からConnect AI の仮想SQL Server API へのコネクションを確立するには以下の手順に従います。

<Steps>
  <Step>
    Microsoft Power Apps にログインします。
  </Step>

  <Step>
    ナビゲーションメニューで**More** -> **接続** を開きます。

    <Frame>
      <img src="https://mintcdn.com/cdata/DDl5yMaSE1cK608F/ja/images/powerautomate_client_01.png?fit=max&auto=format&n=DDl5yMaSE1cK608F&q=85&s=ab771301741ec0852372f7f66fae4854" alt="" width="1355" height="1452" data-path="ja/images/powerautomate_client_01.png" />
    </Frame>
  </Step>

  <Step>
    **新しい接続**をクリックし、利用できる接続のリストを開きます。
  </Step>

  <Step>
    **SQL Server** を選択します。ダイアログが表示されたら、**SQL Server 認証**を選択します。
  </Step>

  <Step>
    接続設定を入力します。

    * **SQL サーバー名**—次のように仮想SQL Server のエンドポイントとポートをカンマで区切って入力します。例：*tds.cdata.com*,*14333*
    * **SQL データベース名**—接続したいConnect AI データソースのConnection Name を入力します。例：*Salesforce1* To connect to a workspace, set the **SQL database name** to the name of your workspace (for example, *MyWorkspace*).
    * **ユーザー名**—Connect AI のユーザー名を入力します。ユーザー名は、Connect AI の画面の右上に表示されています。例：*[test@cdata.co.jp](mailto:test@cdata.co.jp)* To connect to a workspace, set the **Username** to `[CData_username]@[workspace_name]` (for example, *[test@cdata.com](mailto:test@cdata.com)@MyWorkspace*).
    * **パスワード**—[Settings](/ja/Settings#personal-access-tokens) ページで生成したPAT を入力します。
    * **ゲートウェイの選択**は空白のままにします。
      *Connecting to a source*：

    <Frame>
      <img src="https://mintcdn.com/cdata/DDl5yMaSE1cK608F/ja/images/powerapps_create.png?fit=max&auto=format&n=DDl5yMaSE1cK608F&q=85&s=7d3e7b1a5752b3d981fbdfbf49e9585e" alt="" width="755" height="629" data-path="ja/images/powerapps_create.png" />
    </Frame>

    *Connecting to a workspace*：

    <Frame>
      <img src="https://mintcdn.com/cdata/DDl5yMaSE1cK608F/ja/images/powerapps_workspace.png?fit=max&auto=format&n=DDl5yMaSE1cK608F&q=85&s=d628ffcdd21f2e717b19854e0e2a5706" alt="" width="751" height="618" data-path="ja/images/powerapps_workspace.png" />
    </Frame>
  </Step>

  <Step>
    **作成**をクリックし接続を確立します。
  </Step>
</Steps>

これで、接続リストに作成した接続が表示されます。このプロセスを繰り返し、異なる**SQL データベース名** を入力することで、Connect AI アカウントからさらにデータソースを追加することができます。

<Note>
  テーブルにINTEGER カラムの主キーがある場合のみ、Microsoft Power Apps で仮想テーブルをプレビューできます。詳しくは、[Microsoft Power Apps ドキュメント](https://learn.microsoft.com/ja-jp/power-apps/maker/data-platform/limits-tshoot-virtual-tables?tabs=sql)を参照してください。
</Note>

## 詳細

Microsoft Power Apps での SQL Server 接続については、[Microsoft 社のサポート記事](https://docs.microsoft.com/ja-jp/powerapps/maker/canvas-apps/connections/connection-azure-sqldatabase) を参照してください。
