azure_preview_modules icon indicating copy to clipboard operation
azure_preview_modules copied to clipboard

azure_rm_virtualmachine: enable custom storage account

Open Sneedes opened this issue 4 years ago • 0 comments

Attempting to utilize azure_rm_virtualmachine module to define an Azure Virtual Machine with:

  • Boot Diagnostics Enabled
  • Custom Storage Account in a different Resource Group than the VM
  • VM using managed disks

Appears the Ansible module is written in such a way that the VM Boot Diagnostics cannot be enabled with an existing Storage Account that exists outside of the Resource Group of the VM. Noting that this can occur in the Azure Portal/GUI.

Azure Portal> Target VM > Support + troubleshooting > Boot diagnostics >Settings Status: Enable with custom storage account Diagnostics storage account drop-down lists possible Storage Accounts that may be utilized

Encounter the following error message from Ansible:

Error fetching storage account myCustomStorageAccount- Azure Error: ResourceNotFound

Message: The Resource 'Microsoft.Storage/storageAccounts/myCustomStorageAccount' under resource group 'myVMResourceGroup' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

- name: Create Azure VM myVMName
  azure_rm_virtualmachine:
    name: myVMName
    resource_group: myVMResourceGroup
    managed_disk_type: "Premium_LRS"
    boot_diagnostics": {
      enabled: true,
      storage_account: myCustomStorageAccount
$ ansible-config dump --only-changed
INTERPRETER_PYTHON(.ansible.cfg) = auto_silent

$ ansible --version
ansible 2.10.0.dev0
  config file = .ansible.cfg
  configured module search path = [u'.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/ansible/azure-20200212/lib/python2.7/site-packages/ansible
  executable location = /opt/ansible/azure-20200212/bin/ansible
  python version = 2.7.5 (default, Aug 13 2020, 02:51:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

Sneedes avatar Jan 11 '21 22:01 Sneedes