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
810
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.9k
Static Web App の使い方
hajimes
0
2.8k
Azure Functions で SQL Database のデータを操作する API を作成する手順
hajimes
0
1k
Other Decks in Programming
See All in Programming
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
160
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
160
AWS CDK を「作」ってみた 〜フルスクラッチで見えた CDK の裏側〜 / aws-cdk-from-scratch
gotok365
3
2.8k
AI時代のPHPer生存戦略 ~「言語、もうなんでもよくない?」に本気で向き合う~
vivion
0
220
継続モナドとリアクティブプログラミング
yukikurage
3
670
【やさしく解説 設計編・中級 #4】ルールの寿命と、システムの年輪
panda728
PRO
2
180
霧の中の代数的エフェクト
funnyycat
1
450
PostgreSQL 18で考えるUUID主キー
kazuhiro1982
0
450
仕様駆動開発へのトライを機に チームに適合する手法を模索し続けている話
freee
PRO
0
350
アルゴリズムは何を圧縮しているのか ─ Haskell から育った「圧縮代数」というメンタルモデル
naoya
16
3.8k
その節約、円になってますか?
isamumumu
1
670
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
240
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.7k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.4k
Accessibility Awareness
sabderemane
1
170
Between Models and Reality
mayunak
4
380
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
650
Paper Plane (Part 1)
katiecoart
PRO
1
10k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.8k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
330
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
Making the Leap to Tech Lead
cromwellryan
135
10k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.3k
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