For this posting, it is more like an update as i recently found a better way in github (link here) to enable the boot diagnostic to Azure VM .
This is code segment that i use previously
For this posting, it is more like an update as i recently found a better way in github (link here) to enable the boot diagnostic to Azure VM .
This is code segment that i use previously
Previously i have posted a way to import a resource group into terraform. so today it will a continue process to that where it time to import virtual network into terraform .
This will be a bit challenging as it got some dependencies to another resources like Subnet and NSG.
So let begin, so always start with creating a empty of your vnet but for this scenario i will suggest to import NSG first as it was bind with subnet.
Then run the terraform import for this nsg
Terraform import azurerm_network_security_group.nsg-app xx/xxx/xxx/NSG-APP
After that, use terraform show to check what are the information needed for NSG block to match with deployment.
continuing from that, you may start importing the virtual network with the same step and continue with the subnet . i was planning to use one resource block to address vnet and subnet like here
Thanks for reading and stay safe.
As part of using terraform to manage the architecture, there a time when the environment has existing resources or the resource being deploy via portal instead of terraform
So, in order to keep all the control in terraform, the resource need to be imported to terraform so it can be manage from there.
In this case , Azure Resource Group will be imported to terraform, as we all aware, all resource in azure need to be located in resource
1.Start with create an empty block the resource ;
"prod-rg" is just a block name, can be name with any name but i prefer to tally with the resource group name created on Azure.
2. Get the RG resource id from azure portal
For this case - terraform import azurerm_resource_group.prod-rg /xxx/xxx/resourcegroup/PROD-RG
4. After import is complete, some info need to be added into resource group block.
4.1 you may run terraform show to see what need to be added
Not all need to be added
5. Edit the RG block as follow
6. run terraform plan to check if any more information need to be add, but as for now, that two information is enough
That all i have for now, feel free to leave a feedback in the comment, happy terraforming and stay safe
Hello all,
for this time round, i would like to share some fix i have done due to windows VM is not accessible after applying July update . So when the restart was performed, the VM is not responding to RDP and CPU usage is 0.02% from the Azure Portal for few hours. Turn out some error happen on booting up the vm and you can see if VM screen like screenshot below if the boot diagnostic is enable
As usual, the solution will need a temporary VM as fixer and the step as follow
1. Create a Disk Snapshot of affected VM ; name it VM01-snapshot or ss
2. Create a manage disk using VM01-snapshot ; name it VM01-OSdisk-01
3. Create a temporary VM with Hyper V enable ; i name it as HyperV
4. Attach VM01-OSdisk-01 as a data disk to HyperV VM
5. Do a RDP to HyperV vm and open Command Prompt
6. Run "dism /image:G:\ /cleanup-image /revertpendingactions" ; change letter G according to os disk of VM01
7. Once the process completed, go to disk management and "offline" the VM01 Os disk
8. Create a VM in Hyper V; name TestVM, choose Gen1 because most azure vm is Gen1 and during the disk selection, choose attach the disk later.
9. After the TestVM created, right click and go to setting, On IDE click add hard disk and choose physical drive. This will work as Hyper V support pass through disk in normal hyper v deployment which means it will use physical disk instead of virtual hard disk
11. As the vm is boot successfully and the TestVm can be power off, remove from TestVM setting and remove from HyperV vm data disk in azure portal.
12. Perform "Swap OS disk" operation with source vm in Azure portal.
Hope this will help somebody out there , leave a feedback in the comment and stay safe