インストール・アップデート †
インストール †
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
| -
|
!
-
!
-
!
-
!
-
!
-
!
|
Get-Module PowerShellGet -list | Select-Object Name,Version,Path
Install-Module Azure
Install-Module AzureRM
Import-Module Azure
Import-Module AzureRM
Get-Module
|
アカウント †
認証ダイアログでログイン †
1
2
3
4
| -
!
-
!
| Add-AzureAccount
Add-AzureRmAccount
|
クライアント証明書でログイン(ASM) †
- アカウント作成 or 招待
旧ポータル-[設定]-[管理者]-[追加]にて、共同管理者としてアカウントを作成 or 招待する
既存のアカウントに対してクライアント証明書を紐づける場合は不要
- クライアント証明書を作成
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
-
!
| $subject="CN=<紐づけたいアカウント名と同一>"
$expiryDate = (Get-Date).AddYears(100)
$outputFilePath=".\out.cer"
$cert = New-SelfSignedCertificate `
-Subject "${subject}" `
-KeyAlgorithm RSA `
-KeyLength 4096 `
-HashAlgorithm sha256 `
-NotAfter ${expiryDate} `
-CertStoreLocation "Cert:\CurrentUser\My" `
-KeyExportPolicy NonExportable `
-Provider "Microsoft Enhanced Cryptographic Provider v1.0"
Export-Certificate -cert $cert -FilePath "${outputFilePath}"
|
- アカウントにクライアント証明書を紐づける
旧ポータル-[設定]-[管理証明書]-[アップロード]で、作成したout.cerをアップロード
- 動作確認
- まず、完全なログアウト状態を作る
1
2
| -
!
| C:\Users\<ユーザ名>\AppData\Roaming\Windows Azure Powershell
|
- ログイン
1
2
3
4
5
6
7
8
9
10
|
| $fingerPrint = <クライアント証明書のフィンガープリント>
$subscriptionName = <サブスクリプション名>
$subscriptionID = <サブスクリプションID>
$cert = Get-ChildItem Cert:\CurrentUser\My\${fingerPrint}
Set-AzureSubscription `
-SubscriptionName "${subscriptionName}" `
-SubscriptionId "${subscriptionID}" `
-Certificate $cert
Select-AzureSubscription -SubscriptionName "${subscriptionName}"
|
クライアント証明書でログイン(ARM) †
- AADを操作できるアカウントでログイン(ARM)
- AADへサービスプリンパシルを登録
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
-
!
-
|
!
-
!
-
!
| $displayName = "exampleapp"
$subject = "CN=${displayName}"
$expiryDate = (Get-Date).AddYears(100)
$role = "Contributor"
$cert = New-SelfSignedCertificate `
-Subject "${subject}" `
-KeyAlgorithm RSA `
-KeyLength 4096 `
-HashAlgorithm sha256 `
-NotAfter ${expiryDate} `
-CertStoreLocation "Cert:\CurrentUser\My" `
-KeyExportPolicy NonExportable `
-Provider "Microsoft Enhanced Cryptographic Provider v1.0"
$certValue = [System.Convert]::ToBase64String($cert.GetRawCertData())
$sp = New-AzureRMADServicePrincipal `
-DisplayName ${displayName} `
-CertValue ${certValue} `
-EndDate $cert.NotAfter `
-StartDate $cert.NotBefore
Sleep 20
New-AzureRmRoleAssignment `
-RoleDefinitionName ${role} `
-ServicePrincipalName $sp.ApplicationId
|
- ログインに必要な情報の取得
1
2
3
4
5
6
7
8
| -
!
-
!
-
!
| (Get-AzureRmSubscription -SubscriptionName <サブスクリプション名>).TenantId
$sp.ApplicationId
$cert.Thumbprint
|
- 動作確認
- まず、完全なログアウト状態を作る
1
2
| -
!
| C:\Users\<ユーザ名>\AppData\Roaming\Windows Azure Powershell
|
- ログイン
1
2
3
4
5
6
7
8
9
|
| $tenantID = <テナントID>
$applicationID = <アプリケーションID>
$fingerPrint = <クライアント証明書のフィンガープリント>
Login-AzureRmAccount `
-ServicePrincipal `
-TenantId $tenantID `
-ApplicationId $applicationID `
-CertificateThumbprint $fingerPrint
|
サブスクリプション †
サブスクリプションID, テナントID取得 †
1
|
| Get-AzureRmSubscription
|
サブスクリプションが切り替わらない、消えない、増えない、挙動がおかしい †
1
2
3
| -
!
-
| C:\Users\<ユーザ名>\AppData\Roaming\Windows Azure Powershell
|
ロール(ARM) †
ロール一覧取得 †
1
|
| Get-AzureRmRoleDefinition | FT Name, Description
|
ロールの権限確認 †
1
2
|
| Get-AzureRmRoleDefinition <ロール名> | FL Actions, NotActions
(Get-AzureRmRoleDefinition <ロール名>).Actions
|
権限一覧取得 †
1
|
| Get-AzureRMProviderOperation * | Out-GridView
|
ユーザーの権限確認 †
1
2
3
4
5
6
7
8
9
10
11
| -
!
-
!
-
!
-
!
| Get-AzureRmRoleAssignment
Get-AzureRmRoleAssignment -IncludeClassicAdministrators
Get-AzureRmRoleAssignment -SingInName <アカウント名>
Get-AzureRmRoleAssignment -ServicePrincipalName <アプリケーションID>
|
リソースに対するユーザーの権限表示 †
1
|
| Get-AzureRmRoleAssignment -ResourceGroupName <リソースグループ名> | FL DisplayName, RoleDefinitionName, Scope
|
カスタムロールの作成 †
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
| -
!
-
|
!
-
!
-
!
-
!
-
!
|
$role = Get-AzureRmRoleDefinition "Reader"
$role.id = $null
$role.name = "foo"
$role.description = "bar"
$role.Actions.Add("Microsoft.Authorization/*/read")
$role.Actions.Add("Microsoft.ClassicCompute/domainNames/*")
$role.Actions.Add("Microsoft.ClassicCompute/virtualMachines/*")
$role.Actions.Add("Microsoft.ClassicNetwork/reservedIps/link/action")
$role.Actions.Add("Microsoft.ClassicNetwork/reservedIps/read")
$role.Actions.Add("Microsoft.ClassicNetwork/virtualNetworks/join/action")
$role.Actions.Add("Microsoft.ClassicNetwork/virtualNetworks/read")
$role.Actions.Add("Microsoft.ClassicStorage/storageAccounts/disks/read")
$role.Actions.Add("Microsoft.ClassicStorage/storageAccounts/images/read")
$role.Actions.Add("Microsoft.ClassicStorage/storageAccounts/listKeys/action")
$role.Actions.Add("Microsoft.ClassicStorage/storageAccounts/read")
$role.Actions.Add("Microsoft.Insights/alertRules/*")
$role.Actions.Add("Microsoft.ResourceHealth/availabilityStatuses/read")
$role.Actions.Add("Microsoft.Resources/deployments/*")
$role.Actions.Add("Microsoft.Resources/subscriptions/resourceGroups/read")
$role.Actions.Add("Microsoft.Support/*")
$role.AssignableScopes.Clear()
$role.AssignableScopes.Add("/subscriptions/<サブスクリプションID>")
New-AzureRmRoleDefinition -Role $role
|
リソース †
リソース一覧取得 †
1
2
|
| Select-AzureRmSubscription -SubscriptionId <サブスクリプションID>
Get-AzureRmResource | Out-GridView
|
LogAnalytics(旧OMS) †
LogAnalyticsのメリットは、GCP Stackdriver(GCP/AWS)や、AWS CloudWatch(AWS)と違い、どんなクラウド端末でもオンプレ端末でも監視可能という点。
可視化も統合されており、GCPのように別リソースで見るということがない。またStackdriver MonitoringやGoogle DataPortalより遥かに柔軟。
Stackdriver Loggingは長期ログ保存ができず、普通はBigQueryに流すことになるがBigQueryはクエリ実行にコストがかかる上、クエリ構文が冗長かつ検索速度自体もLogAnalyticsより遅い。
デメリットはインジェストコストはStackdriverより高い点と、データのエクスポートが不自由な点。
インストール †
- Azureポータルを開く
- LogAnalyticsの該当リソースを開く
- [詳細設定]-[Connected Sources]-[Linux Servers]
- [LINUX 用エージェントのインストールとオンボード]のコマンドレットをコピー
- 監視したいインスタンス上で、上記コマンドレットを実行
アンインストール †
1
|
| sudo sh ./onboard_agent.sh --purge
|
設定 †
1
2
| -
!
| sudo su omsagent -c 'python /opt/microsoft/omsconfig/Scripts/PerformRequiredConfigurationChecks.py'
|
収集設定の個別設定 †
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| -
!
-
!
-
!
-
|
!
-
!
-
!
| sudo /opt/microsoft/omsconfig/Scripts/OMS_MetaConfigHelper.py --disable
vi /etc/rsyslog.d/95-omsagent.conf
*.* @127.0.0.1:25224
systemctl restart rsyslog
vi /etc/opt/microsoft/omsagent/conf/omsagent.conf
vi /etc/opt/microsoft/omsagent/<ワークスペースID>/conf/omsagent.d/customlog.conf
<source>
type sudo_tail
path /var/log/audit/audit.log
pos_file <posファイルパス(e.g. /var/opt/microsoft/omsagent/state/CUSTOM_LOG_BLOB.audit_CL_foo.pos)>
read_from_head false
run_interval 60
tag <タグ(e.g. oms.blob.CustomLog.CUSTOM_LOG_BLOB.audit_CL_foo.*)>
format none
</source>
chown omsagent:omiusers /etc/opt/microsoft/omsagent/<ワークスペースID>/conf/omsagent.d/customlog.conf
/opt/microsoft/omsagent/bin/service_control restart
/opt/omi/bin/service_control restart
|
その他 †
バージョンの確認 †
1
2
3
4
5
6
7
| -
!
-
!
| Get-Module
Get-Module Azure -list | Select-Object Name,Version,Path
Get-Module AzureRM -list | Select-Object Name,Version,Path
Get-Module -ListAvailable -Name Azure -Refresh
|