Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Application insightsを用いてAzure AD B2Cをより使いこなす

Application insightsを用いてAzure AD B2Cをより使いこなす

Alternative Architecture DOJO #4

Mitsuzono Hiroto

June 18, 2020
Tweet

More Decks by Mitsuzono Hiroto

Other Decks in Technology

Transcript

  1. Azure Application insightsを用いて
    Azure AD B2Cをより使いこなす
    株式会社オルターブース 満園 裕人

    View Slide

  2. • 満園裕人
    • 株式会社オルターブース
    エンジニア
    • 業務では主にC#(.NET Core)で
    Webアプリケーション開発を行う
    自己紹介
    Copyright © Alterbooth Inc. All Rights Reserved. 2

    View Slide

  3. • Application Insights
    • 概要
    • クエリ
    • Azure AD B2Cとの組み合わせ
    • 前準備(カスタムポリシーの構成)
    • 開発環境での設定、活用方法
    • 運用環境での設定、活用方法
    目次
    Copyright © Alterbooth Inc. All Rights Reserved. 3

    View Slide

  4. Application Insights
    Copyright © Alterbooth Inc. All Rights Reserved. 4

    View Slide

  5. • アプリケーションパフォーマンス管理サービス
    • Azure Monitorに統合されている
    • オートスケールやアラートの条件として利用可能
    • Azureポータルからリソース作るとよく勝手についてくる
    • が、論理アプリケーション単位でまとめるのがオススメ
    • アプリ側の設定についてはVisualStudioで行うと楽
    • 手動でやるとNugetの設定やら何やらで面倒
    Application Insights
    Copyright © Alterbooth Inc. All Rights Reserved. 5

    View Slide

  6. • Azure Data Explorerで使われる読み取り専用クエリ
    • Application Insightsの「ログ」ボタンから見れる
    KQL (Kusto Query Language)

    View Slide

  7. Azure AD B2C
    + Application Insights
    Copyright © Alterbooth Inc. All Rights Reserved. 7

    View Slide

  8. • Azure AD B2Cでカスタムポリシーを構成する必要がある
    • 「カスタムポリシーの概要」ページの手順に沿って作成
    • https://docs.microsoft.com/ja-jp/azure/active-directory-
    b2c/custom-policy-get-started
    • 主に↑のカスタムポリシーを書き換えていく前提の内容になって
    います
    Application Insightsを追加する前作業
    Copyright © Alterbooth Inc. All Rights Reserved. 8

    View Slide

  9. Application Insightsの活用
    ―開発環境編―
    Copyright © Alterbooth Inc. All Rights Reserved. 9

    View Slide

  10. • Azure AD B2CはApplication Insightsへのデータ送信機能をもつ
    • https://docs.microsoft.com/ja-jp/azure/active-directory-
    b2c/troubleshoot-with-application-insights
    • IDプロバイダーとの間で送受信されるすべての要求を収集
    • 開発者モードで配置されている場合にのみ収集される
    • 手順
    • Application Insightsのリソースを作成、キーを取得
    • カスタムポリシーを構成(今回はSignUpOrSignin.xmlを編集)
    カスタムポリシーの問題を診断(開発環境のみ)
    Copyright © Alterbooth Inc. All Rights Reserved. 10

    View Slide

  11. カスタムポリシーの問題を診断(開発環境のみ)
    Copyright © Alterbooth Inc. All Rights Reserved. 11

    View Slide

  12. • トレースログとして出力される
    • ログの活用例
    • 細かい情報が見れる
    • エラーが起きたときの原因調査
    • 取れる情報の把握
    • 運用環境でのログ出力(後述)で使う
    プロパティ名の確認など
    カスタムポリシーの問題を診断(開発環境のみ)
    Copyright © Alterbooth Inc. All Rights Reserved. 12

    View Slide

  13. Application Insightsの活用
    ―運用環境編―
    Copyright © Alterbooth Inc. All Rights Reserved. 13

    View Slide

  14. • 前述のものより細かい設定が必要
    • https://docs.microsoft.com/ja-jp/azure/active-directory-
    b2c/analytics-with-application-insights
    • 今回はTrustFrameworkBase.xmlと
    TrustFrameworkBaseExtensions.xmlを編集します(割愛)
    • カスタムイベントとして出力される
    • ユーザー動作の追跡が可能
    ユーザー体験のイベントログ収集(運用環境含む)
    Copyright © Alterbooth Inc. All Rights Reserved. 14

    View Slide

  15. • 「(省略可)さらにデータを収集する」項目の補足
    • Object IDや外部アカウントのIDを取りたい場合もここに追記
    ユーザー体験のイベントログ収集(運用環境含む)
    Copyright © Alterbooth Inc. All Rights Reserved. 15

    View Slide

  16. • LINE ユーザーIDも取れる!
    ユーザー体験のイベントログ収集(運用環境含む)
    Copyright © Alterbooth Inc. All Rights Reserved. 16

    View Slide

  17. • LINE ユーザーIDでフィルタリングもできる!
    ユーザー体験のイベントログ収集(運用環境含む)
    Copyright © Alterbooth Inc. All Rights Reserved. 17

    View Slide

  18. まとめ
    Copyright © Alterbooth Inc. All Rights Reserved. 18

    View Slide

  19. • Application Insightsを組み合わせることによって…
    • 開発時のカスタムポリシーのデバッグを効率化できる
    • エラー詳細
    • ログとして取れる情報の確認
    • 運用時もエラーの検知や原因特定が行いやすくなる
    • 必要な情報のみに絞るための設定が必要
    • アラートルールの追加&Webhookの設定が可能に
    まとめ
    Copyright © Alterbooth Inc. All Rights Reserved. 19

    View Slide

  20. • カスタムポリシーの概要
    • https://docs.microsoft.com/ja-jp/azure/active-directory-
    b2c/custom-policy-get-started
    • カスタムポリシーのトラブルシューティング
    • https://docs.microsoft.com/ja-jp/azure/active-directory-
    b2c/troubleshoot-with-application-insights
    • ユーザー動作の追跡
    • https://docs.microsoft.com/ja-jp/azure/active-directory-
    b2c/analytics-with-application-insights
    参考ドキュメント
    Copyright © Alterbooth Inc. All Rights Reserved. 20

    View Slide

  21. ご清聴ありがとうございました!
    Copyright © Alterbooth Inc. All Rights Reserved. 21

    View Slide