Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Azure App Configuration と Key Vault の連携
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Hajime
June 19, 2022
Programming
750
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Azure App Configuration と Key Vault の連携
Hajime
June 19, 2022
More Decks by Hajime
See All by Hajime
Azure API Management の使い方
hajimes
0
3.7k
Static Web App の使い方
hajimes
0
2.5k
Azure Functions で SQL Database のデータを操作する API を作成する手順
hajimes
0
1k
Other Decks in Programming
See All in Programming
AI時代のUIはどこへ行く?その2!
yusukebe
21
7k
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
160
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
750
さぁV100、メモリをお食べ・・・
nilpe
0
140
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
120
JavaDoc 再入門
nagise
0
320
Oxcを導入して開発体験が向上した話
yug1224
4
300
「エンジニアインターン、どうやって取った?」準備のリアルを語るLT会 Progate BAR
akiomatic
0
130
Claspは野良GASの夢をみるか
takter00
0
180
肥大化するレガシーコードに立ち向かうためのインターフェース分離と依存の逆転 / JJUG CCC 2026 Spring
hirokunimaeta
0
530
Agentic UI
manfredsteyer
PRO
0
130
Modding RubyKaigi for Myself
yui_knk
0
910
Featured
See All Featured
Side Projects
sachag
455
43k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
830
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
GraphQLとの向き合い方2022年版
quramy
50
15k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Building a Scalable Design System with Sketch
lauravandoore
463
34k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Fireside Chat
paigeccino
42
3.9k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
270
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Transcript
Azure App Configuration と Key Vault の連携 (Node.JS 編) (c)
2022 hajimes.life
1. 前提条件と構成 • 実現したいこと • アプリで App Configuration に関連 づけられた
Key Vault のシークレッ ト情報を取得すること • Azure サービス • App Configuration: アプリケーショ ンの設定情報などを⼀元的に管理 • Key Vault: アプリケーションのシー クレット情報などを暗号化して管理 • 実⾏環境 • 処理の流れ 1. Key Vault に値を保存 2. App Configuration に Key Vault への参照情報を登録 3. App Configuration から参照先の Key Vault 情報を取得 4. Key Vault から値を取得 (c) 2022 hajimes.life 環境名 バージョン MacOS 12.4 (Intel) Node.JS v16.15.1 App Configuration Key Vault クライアント 3. 参照先 Key Vault 情報を取得 4. 値を取得 1. Key Vault に値を保存 2. Key Vault への参照情報を登録
2. 今回利⽤する Azure サービスについて App Configuration • 概要︓アプリの設定情報や機能フラ グを⼀元的に管理するサービス。開 発と本番など同じアプリを複数設置
した際の設定ミスを防ぐ • 料⾦︓Free 今回の構成では機能的に Free プラ ンでも実現可能 実運⽤に向けては SLA の定義がなく 1 ⽇のアクセス頻度が 1,000 回なた め Standard プランにした⽅が無難 Key Vault • 概要︓サービスのシークレットや サーバ証明書などの秘匿情報を暗号 化してセキュアに管理するサービス • 料⾦︓Standard 今回の構成では「秘密情報の操作」 のみが課⾦対象となり、 1 万回操作 して $0.03 のコストが発⽣ Standard プランでも SLA が 99.99% で提供されているため、実 運⽤でもプランの変更は不要 (c) 2022 hajimes.life App Configuration の価格 https://azure.microsoft.com/ja-jp/pricing/details/app-configuration/ Key Vault の価格 https://azure.microsoft.com/ja-jp/pricing/details/key-vault/
Key Vault / App Configuration の設定⼿順 1. Key Vault の設定
1. Key Vault の作成 2. 「Secrets」メニューを選択して 「Generate/Import」ボタンを押 す 3. 表⽰された「Create a secret」画 ⾯で必要な項⽬を⼊⼒し作成 2. App Configuration の設定 1. App Configuration の作成 2. 「Configuration Explorer」メ ニューを選択して「Create」ボタ ンを押し「Key Vault reference」 を選択 3. 表⽰された「Create」画⾯で参照 先となる Key Vault のシークレッ トを選択して「Apply」ボタンを 押す (c) 2022 hajimes.life
クライアント側での値の取得⼿順 1. App Configuration から Key Vault の格納先情報を取得 • 事前に
App Configuration の接続⽂ 字列と構成名を取得しておく • 上記のコードで retrievedSetting の value に Key Vault の URI が格納 されている 2. URI から Key Vault に格納さ れているシークレットを取得 • 事前に Key Vault のシークレット名 を取得しておく • 上記コードで secret に値が格納さ れている (c) 2022 hajimes.life const appConfig = require('@azure/app-configurationʼ); const appConfClient = new appConfig.AppConfigurationClient(AC_CONN_STR); const retrievedSetting = await appConfClient.getConfigurationSetting({ key: AC_KEY_NAME }); AC_CONN_STR: App Configuration 接続⽂字列 AC_KEY_NAME: 構成名 const kvUri = new URL(JSON.parse(retrievedSetting.value).uri); const credential = new DefaultAzureCredential(); const kvClient = new SecretClient(kvUri.protocol + '//' + kvUri.hostname, credential); const secret = await kvClient.getSecret(KEY_VAULT_SECRET_NAME); KEY_VAULT_SECRET_NAME: シークレット名
(c) 2022 hajimes.life