问题描述
这是我的脚本:
#在下面正确设置您的Azure VM诊断参数
my_resource_group ="< resource_group_name>""
my_linux_vm ="< vm_name>"
my_diagnostic_storage_account ="< storage_account_name>""
#首先应先登录Azure
az登录
#选择包含存储帐户的订阅
az帐户集-订阅< Subscription_Id>"
#下载示例公共设置. (您也可以使用curl或任何网络浏览器)
wget https://raw.githubusercontent.com/Azure/azure-linux-extensions/master/Diagnostic/tests/lad_2_3_compatible_portal_pub_settings.json -O portal_public_settings.json
#构建虚拟机资源ID.在公共设置中替换存储帐户名和资源ID.
my_vm_resource_id = $(az vm show -g $ my_resource_group -n $ my_linux_vm --query"id" -o tsv)
sed -i"s #__ DIAGNOSTIC_STORAGE_ACCOUNT __#$ my_diagnostic_storage_account#g" portal_public_settings.json
sed -i"s #__ VM_RESOURCE_ID __#$ my_vm_resource_id#g" portal_public_settings.json
#构建受保护的设置(存储帐户SAS令牌)
my_diagnostic_storage_account_sastoken = $(az存储帐户generate-sas-帐户名$ my_diagnostic_storage_account-到期2037-12-31T23:59:00Z --permissions wlacu --resource-types co --services bt -o tsv)
my_lad_protected_settings =" {'storageAccountName':'$ my_diagnostic_storage_account','storageAccountSasToken':'$ my_diagnostic_storage_account_sastoken'}'''
回声$ my_diagnostic_storage_account_sastoken
回声$ my_lad_protected_settings
#最终告诉Azure安装并启用扩展
az vm扩展集--publisher Microsoft.Azure.Diagnostics --name LinuxDiagnostic --version 3.0 --resource-group $ my_resource_group --vm-name $ my_linux_vm --protected-settings"$ {my_lad_protected_settings}" --settings portal_public_settings.json
# Set your Azure VM diagnostic parameters correctly below
my_resource_group="<resource_group_name>"
my_linux_vm="<vm_name>"
my_diagnostic_storage_account="<storage_account_name>"
# Should login to Azure first before anything else
az login
# Select the subscription containing the storage account
az account set --subscription "<Subscription_Id>"
# Download the sample Public settings. (You could also use curl or any web browser)
wget https://raw.githubusercontent.com/Azure/azure-linux-extensions/master/Diagnostic/tests/lad_2_3_compatible_portal_pub_settings.json -O portal_public_settings.json
# Build the VM resource ID. Replace storage account name and resource ID in the public settings.
my_vm_resource_id=$(az vm show -g $my_resource_group -n $my_linux_vm --query "id" -o tsv)
sed -i "s#__DIAGNOSTIC_STORAGE_ACCOUNT__#$my_diagnostic_storage_account#g" portal_public_settings.json
sed -i "s#__VM_RESOURCE_ID__#$my_vm_resource_id#g" portal_public_settings.json
# Build the protected settings (storage account SAS token)
my_diagnostic_storage_account_sastoken=$(az storage account generate-sas --account-name $my_diagnostic_storage_account --expiry 2037-12-31T23:59:00Z --permissions wlacu --resource-types co --services bt -o tsv)
my_lad_protected_settings="{'storageAccountName': '$my_diagnostic_storage_account', 'storageAccountSasToken': '$my_diagnostic_storage_account_sastoken'}"
echo $my_diagnostic_storage_account_sastoken
echo $my_lad_protected_settings
# Finallly tell Azure to install and enable the extension
az vm extension set --publisher Microsoft.Azure.Diagnostics --name LinuxDiagnostic --version 3.0 --resource-group $my_resource_group --vm-name $my_linux_vm --protected-settings "${my_lad_protected_settings}" --settings portal_public_settings.json
推荐答案
#在下面正确设置您的Azure VM诊断参数
my_resource_group ="< resource_group_name>""
my_linux_vm ="< vm_name>"
my_diagnostic_storage_account ="< storage_account_name>""
#首先登录Azure
az登录
#选择包含存储帐户的订阅
az帐户集-订阅< Subscription_Id>"
#下载示例公共设置.
# Set your Azure VM diagnostic parameters correctly below
my_resource_group="<resource_group_name>"
my_linux_vm="<vm_name>"
my_diagnostic_storage_account="<storage_account_name>"
# log in to Azure first before anything else
az login
# Select the subscription containing the storage account
az account set --subscription "<Subscription_Id>"
# Download the sample Public settings.
wget https://raw.githubusercontent.com/Azure/azure-linux-extensions/master/Diagnostic/tests/lad_2_3_compatible_portal_pub_settings.json -O portal_public_settings .json
wget https://raw.githubusercontent.com/Azure/azure-linux-extensions/master/Diagnostic/tests/lad_2_3_compatible_portal_pub_settings.json -O portal_public_settings.json
#构建虚拟机资源ID.在公共设置中替换存储帐户名和资源ID.
my_vm_resource_id =
# Build the VM resource ID. Replace storage account name and resource ID in the public settings.
my_vm_resource_id=
这篇关于在Linux VM中启用诊断设置的Azure Cli脚本-不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!