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
Hajime
June 19, 2022
Programming
770
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.8k
Static Web App の使い方
hajimes
0
2.6k
Azure Functions で SQL Database のデータを操作する API を作成する手順
hajimes
0
1k
Other Decks in Programming
See All in Programming
吝嗇家のためのAI活用 / AI development for miser - ChatGPT + Issue Driven Development
tooppoo
0
170
AI駆動開発を妨げる技術的負債の解消アプローチ / ai-refactoring-approach
minodriven
17
8.5k
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
150
act1-costs.pdf
sumedhbala
0
160
[2026年度第1回ORセミナー] 計画最適化ベンチャーと競技プログラミング人材
terryu16
0
290
Vite+ Unified Toolchain for the Web
naokihaba
0
410
代数的データ型って何が嬉しいの? #frontend_phpcon_do
kajitack
9
3.9k
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
1
180
鹿野さんに聞く!『TypeScriptコードレシピ集』で磨く実践力
tonkotsuboy_com
4
970
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
380
自作OSでスライド発表する
uyuki234
1
3.6k
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Evolving SEO for Evolving Search Engines
ryanjones
0
230
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
180
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
The SEO Collaboration Effect
kristinabergwall1
1
500
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.7k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
330
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
630
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
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