#author("2020-08-06T00:09:24+00:00","","")
#author("2020-08-07T03:35:11+00:00","","")
#mynavi(Azureメモ)
#setlinebreak(on);

* 概要 [#dadf4db4]
#html(<div class="pl10">)
#TODO
#html(</div>)

* 目次 [#g9c9f576]
#contents
- 関連
-- [[Azureメモ]]
- 参考
-- https://grafana.com/docs/grafana/latest/auth/ldap/
-- https://grafana.com/docs/grafana/latest/auth/ldap/#active-directory
-- https://grafana.com/docs/grafana/latest/auth/azuread/
-- https://techexpert.tips/ja/grafana-ja/active-directory%E3%81%A7%E3%81%AEgrafana-ldap%E8%AA%8D%E8%A8%BC/

* Azure上のGrafanaでAD認証 [#z729c1d5]
* Azure に Grafana をデプロイする方法 [#s527b860]
#html(<div class="pl10">)
#html(</div>)

まず、Grafana をどのようにして Azure に配備するかについては、いくつか方法がある。

* Azure に Grafana をデプロイする方法 [#s527b860]
#html(<div class="pl10">)

|  作成方法 | 補足 |h
| マーケットプレイスを利用して作成 | ただし ver 6.2.5 の Grafana が構築される( 2020/7時点 ) |
| 自力で構成を作成 | VM、VNet など全てのリソースを自力で作成。 |
| マーケットプレイスを利用して作成 | ただし ver 6.2.5 の Grafana が構築される( 2020/8 時点 ) |
| App Service で作成 | App Service で Docker コンテナ  を利用して作成。( プレビュー版だが、docker-compose も使用できる ) |
| 自力で作成 | VM、VNet など全てのリソースを自力で作成。 |

「全て自力で作成」 する場合と「マーケットプレイスで作成」する場合では、最終的に出来上がる構成はほぼ同じになるが、
マーケットプレイスから作成する場合、Grafana のバージョンは 6.2.5 となる。( 2020/8 時点 )

この記事では、「自力で構成を作成」 「App Service で作成」 で以下の構成を作成する。

#TODO

#html(</div>)

* App Service で作成 [#c3d0621a]
#html(<div class="pl10">)

* マーケットプレイスから構成を作成 [#pc30849d]
App Service  で Docker コンテナーを利用して Grafana 環境を作成する。(2020/8 時点でプレビュー版だが docker-compose も使用できる)
また、今回のように仮想プライベートネットワークへのアクセスが必要な場合、「VNet統合」 を利用する事になるが、この場合 App Service のプランとして Standard または Premium を選ぶ必要がある。

** 実装 [#hf9bff3e]
#html(<div class="pl10">)

https://docs.microsoft.com/ja-jp/azure/azure-monitor/platform/grafana-plugin
docker-compose.yml
#mycode2(){{
  grafana:
    image: grafana/grafana:7.1.1
    hostname: grafana_sample
    container_name: grafana_sample
    ports:
      - "3000:3000"
    volumes:
      - ./grafana.ini:/etc/grafana/grafana.ini
    environment:
      - GF_SERVER_ROOT_URL=http://localhost:3000
      - GF_SECURITY_ADMIN_PASSWORD=admin
}}

vim size: 2 x Standard DS1 v2
vm user:  grafana/grafana1234!
admin user: admin/admin
ストレージアカウント:  dmagagrafana
Domain name for Grafana: dmagagrafana    (dmagagrafana.japanwest.cloudapp.azure.com)
grafana.ini (抜粋)
#mycode2(){{
[auth.azuread]
name = Azure AD
enabled = true
client_id = クライアントID
client_secret = クライアントシークレット
;scopes = openid email profile
auth_url = https://login.microsoftonline.com/テナントID/oauth2/v2.0/authorize
token_url = https://login.microsoftonline.com/テナントID/oauth2/v2.0/token
;allowed_domains =
;allowed_groups =
; 正常に動作しない (常に Viewer になってしまう )
;role_attribute_path = contains(info.groups[*], 'admin') && 'Admin' || contains(info.groups[*], 'editor') && 'Editor' || 'Viewer'
role_attribute_path = contains(groups[*], 'admin') && 'Admin' || contains(groups[*], 'editor') && 'Editor' || 'Viewer'
}}

※バージョン: 6.2.5 の Grafana が構築される。
イメージをビルド
#myterm2(){{
#TODO
}}

#html(</div>)

* App Service で作成 [#c3d0621a]
** デプロイ [#z96616f6]
#html(<div class="pl10">)
#myterm2(){{
az webapp up --sku B1 -n アプリ名 -l  リージョン -g リソースグループ
}}
#html(</div>)

App Service  で Docker コンテナー  を利用して作成。
※プレビュー版だが、docker-compose も使用できる。

#html(</div>)
// App Service で作成


* 自力で作成 [#kfb4523d]
#html(<div class="pl10">)

VM、VNet など全てのリソースを自力で作成。
自力作成は [[Azure FunctionsからVMにアクセスする]] でも実施済み。

#html(</div>)


* Azure AD OAuth2 authentication [#u1e00865]
* Azure AD認証を設定する [#n828409e]
#html(<div class="pl10">)

Azure AD OAuth2 authentication
https://grafana.com/docs/grafana/latest/auth/azuread/

#html(</div>)

Microsoft ID プラットフォームと暗黙的な許可のフロー (暗黙的な許可フローの有効有効化)
https://docs.microsoft.com/ja-jp/azure/active-directory/develop/v2-oauth2-implicit-grant-flow#send-the-sign-in-request

#mycode3(){{
ID トークンおよびアクセス トークンを正しく要求するには、Azure portal の [アプリの登録] ページのアプリ登録で、
 [暗黙の付与] セクションの [ID トークン] および [アクセス トークン] を選択して、対応する暗黙的な許可フローを有効にする必要があります。
それが有効でない場合は、unsupported_response エラーが返されます
}}


トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS