Learn how to use the Set-AzVMDiagnosticsExtension PowerShell cmdlet to enable Azure VM diagnostics when the storage account is in a different subscription. Step-by-step solution explained.
Table of Contents
Question
You need to collect application logs from an Azure Virtual Machine (VM). You use the Set-AzVMDiagnosticsExtension PowerShell cmdlet to enable the diagnostics extension on the VM you created through the Resource Manager deployment mode. However, the diagnostics storage account is in a different subscription from the VM and the cmdlet is unable to get the key automatically. What should you do to resolve this issue?
A. You need to remove the StorageAccountName parameter and specify the key through the StorageAccountKey parameter to the cmdlet.
B. You need to manually set the diagnostics extension to send diagnostic data to that storage account using the Azure classic deployment model.
C. You need to explicitly pass in the StorageAccountName parameter and specify the key through the StorageAccountKey parameter to the cmdlet.
D. You need to disable the diagnostics extension and recreate a Windows VM through the Azure classic deployment model.
Answer
To resolve the issue where the Set-AzVMDiagnosticsExtension cmdlet cannot automatically retrieve the storage account key because the diagnostics storage account is in a different subscription from the Azure Virtual Machine (VM), follow these steps:
C. You need to explicitly pass in the StorageAccountName parameter and specify the key through the StorageAccountKey parameter to the cmdlet.
Explanation
Problem Context
- The Set-AzVMDiagnosticsExtension cmdlet configures diagnostics on Azure VMs.
- When the diagnostics storage account is in a different subscription, the cmdlet cannot automatically retrieve the storage account key, leading to errors.
Solution
- You must explicitly pass both the StorageAccountName and StorageAccountKey parameters to the cmdlet.
- This ensures that diagnostic data can be sent to a storage account in a different subscription.
Implementation
Use the following PowerShell command:
Set-AzVMDiagnosticsExtension -ResourceGroupName $vm_resourcegroup ` -VMName $vm_name ` -DiagnosticsConfigurationPath $diagnosticsconfig_path ` -StorageAccountName $diagnosticsstorage_name ` -StorageAccountKey $diagnosticsstorage_key
Replace $vm_resourcegroup, $vm_name, $diagnosticsconfig_path, $diagnosticsstorage_name, and $diagnosticsstorage_key with your specific values.
Why Other Options Are Incorrect
Option A: Removing StorageAccountName and specifying only StorageAccountKey will not work, as both parameters are required for cross-subscription configurations.
Option B: Switching to Azure classic deployment mode is unnecessary and outdated for modern Resource Manager-based deployments.
Option D: Recreating the VM is irrelevant; this does not address the issue of cross-subscription diagnostics configuration.
By explicitly passing both parameters, you enable diagnostics data collection successfully across subscriptions without recreating or modifying deployment modes.
Developing Microsoft Azure AI Solutions skill assessment practice question and answer (Q&A) dump including multiple choice questions (MCQ) and objective type questions, with detail explanation and reference available free, helpful to pass the Developing Microsoft Azure AI Solutions exam and earn Developing Microsoft Azure AI Solutions certification.