目次
- 前提
- 構成に必要な設定値一覧
- 構成手順
- 参考情報
前提
以下 Power Apps から App Configuration 上のキーバリューにセキュアアクセスするシナリオを実現する為のステップバイステップガイドを提供します。
本シナリオで想定しているフローは以下の通りです。
- Power Apps アプリ上で2つの値(App Configuration構成ストアの”キー”と”ラベル”を指定し、ボタン押下アクションを実行し、Power Automate を開始する。
- Power Automate から認証ポリシーで保護された Logic Apps フローを実行試行し、Power Automate HTTP アクションに設定した Entra ID アプリケーション情報が認証ポリシーと合致すれば、Logic Apps フローがパラメーター指定され開始する。
- Logic Apps から Function App を実行試行し、Function に設定された認証設定/プロバイダー情報に Logic Apps に設定された Managed Identities 情報と合致すれば、Function App がパラメーター指定され開始する。
- Function App が App Configuration に接続試行を行い、Function に設定された Managed Identities の RBAC 設定が App Configuration に設定されていれば、App Configuration からのバリュー取得試行を行う。
- パラメーター指定されたキー/ラベルを元にバリューがFunction App に返され、同じく HTTP アクション実行後の Body を待機する Logic Apps/Power Automate に返され、最終的に Power Apps の ReturnBody 変数に格納される。
上記シナリオはユーザーインターフェース上での実行~ユーザーインターフェース上への値の応答までをエンド・ツー・エンドで実現する為のものですが、実際は Logic Apps のパラメーターとして利用する等、要件に応じて実装対象を検討します。
構成に必要な設定値一覧
以下構成手順を進めて頂く中で設定/収集する設定値一覧テーブルです。
煩雑になりがちですのでお手元のメモ代わりにご利用下さい。
設定名 | 例 | 設定値 | 備考 |
---|---|---|---|
Memo.DirectoryID |
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | Azure AD テナントID | |
Memo.AppConf.Endpoint |
https://xxx.azconfig.io | App Configuration のエンドポイント値 | |
Memo.Func.ManagedID |
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | Function App のシステム割り当てマネージドIDのオブジェクトID | |
Memo.LA.ManagedID |
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | Logic App のシステム割り当てマネージドIDのオブジェクトID | |
Memo.LA.EntraApp.ID |
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | Logic App 認証用のEntra ID アプリのアプリケーションID | |
Memo.LA.EntraApp.URI |
api:sample-api | Logic App 認証用のEntra ID アプリのAPI URI | |
Memo.PA.EntraApp.ID |
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | Power Automate 認証用のEntra ID アプリのアプリケーションID | |
Memo.PA.EntraApp.SC |
XxxxxxxXXXxxxxxxxxxx | Power Automate 認証用のEntra ID アプリのシークレット | |
Memo.LA.POSTURL |
https://xxx.logic.azure.com~api-version=2016-10-01 | Logic App HTTP コール用URL |
構成手順
リソースの作成
App Configuration リソースの作成
a. Azure ポータルから以下設定値で App Configuration リソースを作成します。
設定名 | 設定値 |
---|---|
Subscription |
リソースを作成するサブスクリプションを指定 |
Resource Group |
リソースを作成するリソースグループを指定、もしくは新規作成 |
Location |
リソースを作成するリージョンを指定 |
Resource Name |
任意のアプリ識別名を入力 |
Pricing Tier |
Free |
b. Endpoint値をMemo.AppConf.Endpoint
としてメモします。
Functions リソースの作成
a. Azure ポータルから以下設定値でFunctions リソースを作成します。
設定名 | 設定値 |
---|---|
Subscription |
リソースを作成するサブスクリプションを指定 |
Resource Group |
リソースを作成するリソースグループを指定、もしくは新規作成 |
Function App Name |
任意のアプリ識別名を入力 |
Code or Container |
Code |
Runtime stack |
Node.js |
Version |
18 LTS |
Region |
リソースを作成するリージョンを指定 |
Operating System |
Windows |
Hosting |
Consumption |
b. Node.jsアプリで参照するアプリケーション設定を追加します。
設定名 | 設定値 |
---|---|
AZURE_APPCONFIG_ENDPOINT |
Memo.AppConf.Endpoint |
AzureWebJobsFeatureFlags |
EnableWorkerIndexing |
c. システム割り当てマネージドIDを有効化し、Memo.Func.ManagedID
としてObject IDをメモします。
Logic Apps リソースの作成
a. Azureポータルから以下設定値でLogic Appsリソースを作成します。
設定名 | 設定値 |
---|---|
Subscription |
リソースを作成するサブスクリプションを指定 |
Resource Group |
リソースを作成するリソースグループを指定、もしくは新規作成 |
Logic App name |
任意のアプリ識別名を入力 |
Region |
リソースを作成するリージョンを指定 |
Enable Log Analytics |
No |
Plan type |
Consumption |
b. システム割り当てマネージドIDを有効化し、Memo.LA.ManagedID
としてObject IDをメモします。
App Configuration/Function App間の保護
App Configuration への RBAC 設定
Function AppのマネージドID(Memo.Func.ManagedID
)に対してApp Configuration Data Owner
ロールを割り当てます。
Function App/Logic Apps間の保護
Function App への認証設定
作成したFunction Appの”Authentication”メニューを展開し、”Add provider”を選択後、以下設定値で認証プロバイダー設定を追加します。
設定名 | 設定値 |
---|---|
Identity Provider |
Microsoft |
App registration type |
Provide the details of an existing app registration |
Application(client) Id |
Memo.LA.ManagedID |
Client Secret |
空白 |
Issuer URL |
https://sts.windows.net/`Memo.DirectoryID` |
Allowed token audiences |
https://management.azure.com |
Restrict access |
Require authentication |
Unauthenticated requests |
HTTP 401 |
Logic Apps/Power Automate間の保護
Logic Apps 認証用 Entra ID アプリ作成
a. Azure ポータルで Azure Active Directory メニューを開き、”App registration”を選択し新規アプリを以下設定値で登録します。
設定名 | 設定値 |
---|---|
Name |
任意のアプリ識別名を入力 |
Supported account types |
Accounts in this organizational directory only |
Redirect URI |
空白 |
b. 作成したアプリのApplication IDをMemo.LA.EntraApp.ID
としてメモします。
c. 作成したアプリの”Expose an API”メニューからApplication ID URIを設定しMemo.LA.EntraApp.URI
としてメモします。
d. API スコープを追加します。
Power Automate 認証用 Entra ID アプリ作成
a. Azure ポータルで Azure Active Directory メニューを開き、”App registration”を選択し新規アプリを以下設定値で登録します。
設定名 | 設定値 |
---|---|
Name |
任意のアプリ識別名を入力 |
Supported account types |
Accounts in this organizational directory only |
Redirect URI |
空白 |
b. 作成したアプリのApplication IDをMemo.PA.EntraApp.ID
としてメモします。
c. 作成したアプリにクライアントシークレットを作成し、生成された値をMemo.PA.EntraApp.SC
としてメモします。
Logic Apps への認証ポリシー構成
a. 作成したLogic Appリソースの”Authorization”メニューより”Add policy”を選択後、以下設定値でポリシーを作成します。
クレーム種別 | 名前 | 値 |
---|---|---|
Standard | Issuer |
https://sts.windows.net/`Memo.DirectoryID` |
Standard | Audience |
Memo.LA.EntraApp.ID |
Custom | appid |
Memo.PA.EntraApp.ID |
Function Appへのアプリ展開
Visual Studio Code からの Function プロジェクトの展開
本レポジトリをフォーク、もしくはコードをダウンロードし、ディレクトリをVisual Studio Codeで開いた上で Azure 上 Function App リソースへコードデプロイします。
Develop Azure Functions by using Visual Studio Code
Logic Apps フローの作成
”HTTP要求をパラメーター付きで受け取り、Function Appをトリガーし状態コード、及びBodyをHTTP応答する”フローを作成します。
各フロー内アクションの設定値は以下の通りです。
- When a HTTP request is received
設定名 | 設定値 |
---|---|
HTTP POST URL |
自動生成 |
Request Body JSON Schema |
{ "key":"", "label":"" } ※Use sample payload to generate schemaから上記サンプルスキーマを入力し生成 |
フロー保存時に自動生成されるHTTP POST URLを以下規則に則り編集し、Memo.LA.POSTURL
としてメモします。
- LogicAppHttpTrigger
設定名 | 設定値 |
---|---|
Request Body |
空白 |
Method |
GET |
Queries |
{ "key":HTTPトリガーから key を参照, "label":HTTPトリガーから label を参照 } |
Authentication type |
Managed identity |
Managed identity |
System-assigned managed identity |
Audience |
https://management.azure.com |
- Response on Success
設定名 | 設定値 |
---|---|
Status Code |
200 |
Headers |
空白 |
Body |
FunctionアクションからBody を参照 |
Power Automateフローの作成
”Power Appsから要求をパラメーター付きで受け取り、Logic Appsフローをトリガーし返ってきたBodyを応答する”フローを作成します。
各フロー内アクションの設定値は以下の通りです。
- PowerApps (V2)
設定名 | 設定値 |
---|---|
key |
key value |
label |
label value |
- HTTP
設定名 | 設定値 |
---|---|
方法 |
POST |
URI |
Memo.LA.POSTURL |
本文 |
{ "key": PowerAppsトリガーから key を参照, "label": PowerAppsトリガーから label を参照 } |
認証 |
Active Directory OAuth |
テナント |
Memo.DirectoryID |
対象ユーザー |
Memo.LA.EntraApp.ID |
クライアントID |
Memo.PA.EntraApp.ID |
資格情報の種類 |
シークレット |
シークレット |
Memo.PA.EntraApp.SC |
- PowerApp または Flow に応答する
設定名 | 設定値 |
---|---|
Return |
HTTPアクションから本文 を参照 |
Power Apps アプリの作成
ここまで作成してきた Power Automate フロー、並びに Logic Apps フローにパラメータ付きで要求を送信する為の Power Apps アプリを作成します。 主要な画面上の項目は以下の通りです。
各項目に設定した関数は以下の通りです。
項目名 | プロパティ | 関数 |
---|---|---|
Dropdown1 |
Items | ["SecurityPolicy01","SecurityPolicy02"] |
Dropdown1_1 |
Items | ["v1","v2"] |
Button1 |
OnSelect | Set(ReturnBody ,'POC-AppConf-Bridge'.Run(Dropdown1.SelectedText.Value,Dropdown1_1.SelectedText.Value).return) |
Label3 |
Text | ReturnBody |
事前に作成した Power Automate フローを関連付けておきます。
参考情報
Set up Azure App Service access restrictions
Enable authentication for function calls