Azure仮想マシンスケールセット (VMSS) は、同一のVMセットを展開および管理する機能を提供します。VMの数は、設定可能なスケーリングルールに基づいて自動的に増減します。詳細については、Azureの仮想マシンスケールセットとは?をご覧ください
VMSSを設定して、Deep Securityエージェントが事前インストールおよび事前アクティベートされたベースVMイメージを含めることができます。VMSSがスケールアップすると、スケールセット内の新しいVMインスタンスには自動的にエージェントが含まれます。
AgentをVMSSに追加するには:
Step 1: (推奨) AzureアカウントをDeep Security Managerに追加する
AzureアカウントをDeep Security Managerに追加すると、そのアカウントで作成されたすべてのAzureインスタンスがDeep Security
Managerに読み込まれ、[コンピュータ]に表示されます。エージェントがインストールされているかどうかに関係なく、インスタンスは表示されます。エージェントが含まれていないインスタンスには、[ステータス]として[Agentなし]が表示されます。エージェントをインストールしてアクティブ化すると、その[ステータス]は[管理済み (オンライン)]に変更されます。
スケールセットが手動または自動でスケールアップされた後にAzureアカウントを追加すると、Deep Securityは新しいAzureインスタンスを検出し、[コンピュータ]のリストに追加します。同様に、スケールセットがスケールダウンされると、インスタンスは表示から削除されます。このようにして、Deep Security Managerは常にスケールセット内の利用可能なAzureインスタンスの最新リストを表示します。
ただし、AzureアカウントをDeep Security Managerに追加せず、別の方法で個々のAzureインスタンスを追加した場合、Deep Securityは発生する可能性のあるスケールダウンを検出せず、存在しないAzureインスタンスをリストから削除しません。Deep
Security ManagerのAzure VMリストが拡大し続けるのを防ぎ、スケールセット内で利用可能なAzureインスタンスを常に正確に表示するために、AzureアカウントをDeep
Security Managerに追加することを強くお勧めします。
Azureアカウントの追加手順については、 Deep SecurityにMicrosoft Azureアカウントを追加するを参照してください。
ステップ2: デプロイスクリプトを準備する
Deep Security Managerで、Deep Security Managerからデプロイメントスクリプトを準備します。手順については、デプロイメントスクリプトを使用してコンピュータを追加および保護するを参照してください。このデプロイメントスクリプトは、次に設定するカスタムスクリプト拡張機能で参照されます。
![]() |
注意次のVMSSスクリプトでカスタムスクリプトを実行するには、スクリプトをAzure Blobストレージまたは有効なURLでアクセス可能な他の場所に保存する必要があります。Azure
Blobストレージにファイルをアップロードする方法については、Azure PowerShellを使用してAzure Blobストレージ操作を実行するを参照してください。
|
ステップ3: カスタムスクリプト拡張機能を通じてVMSSインスタンスにエージェントを追加する
以下は、PowerShellを使用してエージェントを追加する方法の例です。
両方の例:
-
Add-AzureRmVmssExtension cmdletを使用して、VMSSに拡張機能を追加します
-
Azure PowerShell バージョン 5.1.1 を使用
![]() |
注意PowerShellコマンドレットを使用して新しいVMSSを作成する手順については、このMicrosoftのチュートリアルを参照してください。Linuxプラットフォームについては、https://github.com/Azure/custom-script-extension-linuxを参照してください。
|
例1: Agentを含む新しいVMSSを作成する
$resourceGroupName = <VMSSのリソースグループ>
$vmssname = <VMSSの名前>
# Create ResourceGroup
New-AzureRmResourceGroup -ResourceGroupName $resourceGroupName -Location EastUS
# Create a config object
$vmssConfig = New-AzureRmVmssConfig `
-Location EastUS `
-SkuCapacity 2 `
-SkuName Standard_DS2 `
-UpgradePolicyMode Automatic
# Define the script for your Custom Script Extension to run on the Windows Platform
$customConfig = @{
"fileUris" = (,"A URL of your copy of deployment script, ex. deploymentscript.ps1");
"commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File deploymentscript.ps1"
}
# Define the script for your Custom Script Extension to run on the Linux Platform
#$customConfig = @{
# "fileUris" = (,"A URL of your copy of deployment script, ex. deploymentscript.sh");
# "commandToExecute" = "bash deploymentscript.sh"
#}
# The section is required only if deploymentscript has been located within Azure StorageAccount
$storageAccountName = <Azure Storageに配置されている場合のStorageAccountName>
$key = (Get-AzureRmStorageAccountKey -Name $storageAccountName -ResourceGroupName
$resourceGroupName).Value[0]
$protectedConfig = @{
"storageAccountName" = $storageAccountName;
"storageAccountKey" = $key
}
# Use Custom Script Extension to install Deep Security Agent (Windows)
Add-AzureRmVmssExtension -VirtualMachineScaleSet $vmssConfig `
-Name "customScript" `
-Publisher "Microsoft.Compute" `
-Type "CustomScriptExtension" `
-TypeHandlerVersion 1.8 `
-Setting $customConfig `
-ProtectedSetting $protectedConfig
# Use Custom Script Extension to install Deep Security Agent (Linux)
#Add-AzureRmVmssExtension -VirtualMachineScaleSet $vmssConfig `
# -Name "customScript" `
# -Publisher "Microsoft.Azure.Extensions" `
# -Type "customScript" `
# -TypeHandlerVersion 2.0 `
# -Setting $customConfig `
# -ProtectedSetting $protectedConfig
# Create a public IP address
# Create a frontend and backend IP pool
# Create the load balancer
# Create a load balancer health probe on port 80
# Create a load balancer rule to distribute traffic on port 80
# Update the load balancer configuration
# Reference a virtual machine image from the gallery
# Set up information for authenticating with the virtual machine
# Create the virtual network resources
# Attach the virtual network to the config object
# Create the scale set with the config object (this step might take a few minutes)
New-AzureRmVmss `
-ResourceGroupName $resourceGroupName `
-Name $vmssname `
-VirtualMachineScaleSet $vmssConfig
例2: 既存のVMSSにエージェントを追加する
$resourceGroupName = <VMSSのリソースグループ>
$vmssname = <VMSSの名前>
# Get the VMSS model
$vmssobj = Get-AzureRmVmss -ResourceGroupName $resourceGroupName -VMScaleSetName $vmssname
# Show model data if you prefer
# Write-Output $vmssobj
# Define the script for your Custom Script Extension to run on the Windows platform
$customConfig = @{
"fileUris" = (,"A URL of your copy of deployment script, ex. deploymentscript.ps1");
"commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File deploymentscript.ps1"
}
# Define the script for your Custom Script Extension to run on the Linux platform
#$customConfig = @{
# "fileUris" = (,"A URL of your copy of deployment script, ex. deploymentscript.sh");
# "commandToExecute" = "bash deploymentscript.sh"
#}
# The section is required only if deploymentscript has been located within Azure StorageAccount
$storageAccountName = <Azure Storageに配置されている場合のStorageAccountName>
$key= (Get-AzureRmStorageAccountKey -Name $storageAccountName -ResourceGroupName $resourceGroupName).Value[0]
$protectedConfig = @{
"storageAccountName" = $storageAccountName;
"storageAccountKey" = $key
}
# Use Custom Script Extension to install Deep Security Agent (Windows)
$newvmssobj = Add-AzureRmVmssExtension `
-VirtualMachineScaleSet $vmssobj `
-Name "customScript" `
-Publisher "Microsoft.Compute" `
-Type "CustomScriptExtension" `
-TypeHandlerVersion 1.8 `
-Setting $customConfig `
-ProtectedSetting $protectedConfig
# Use Custom Script Extension to install Deep Security Agent (Linux)
#$newvmssobj = Add-AzureRmVmssExtension `
# -VirtualMachineScaleSet $vmssobj `
# -Name "customScript" `
# -Publisher "Microsoft.Azure.Extensions" `
# -Type "customScript" `
# -TypeHandlerVersion 2.0 `
# -Setting $customConfig `
# -ProtectedSetting $protectedConfig
# Update the virtual machine scale set model
Update-AzureRmVmss -ResourceGroupName $resourceGroupName -name $vmssname -VirtualMachineScaleSet
$newvmssobj -Verbose
# Get Instance ID for all instances in this VMSS, and decide which instance you'd
like to update
# Get-AzureRmVmssVM -ResourceGroupName $resourceGroupName -VMScaleSetName $vmssname
# Now start updating instances
# If upgradePolicy is Automatic in the VMSS, do NOT execute the next command Update-AzureRmVmssInstance.
Azure will auto-update the VMSS.
# There's no PowerShell command to update all instances at once. But you could refer
to the output of Update-AzureRmVmss, and loop all instances into this command.
Update-AzureRmVmssInstance -ResourceGroupName $resourceGroupName -VMScaleSetName $vmssname
-InstanceId 0