Is there an option to filter VMs based on network in Azure Java SDK? - azure

I tried listing the VMs based on Resource Groups but i want to list the VMs based on network.
Can someone help me with this?
PagedList<VirtualMachine> resourceGroupVMs =
azure.virtualMachines()
.listByResourceGroup(resourceGroupName);

As I known, all of Azure SDK APIs are just calling the related REST APIs. So according to the REST API references for Virtual Machine, as below, you see there is not an API to list VMs by network.
Note: The List API in the figure above is to list VMs by resource group as the description said,
Lists all of the virtual machines in the specified resource group. Use the nextLink property in the response to get the next page of virtual machines.
So the workaround in Java to list VMs by network is to use azure.virtualmachines().listAll() to list all VMs and filter the results with the network profile for echo VM to get those you want.

Related

Using PowerShell to get the Vnet name by resource ID in Azure

Assuming I have an Azure resource ID
Such as:
"/subscriptions/XXXXXXXX/resourceGroups/YYYYYY/providers/Microsoft.ZZZZ/WWWWW/my-resource-name"
How can I find out to which Vnets its connected/sits in using PowerShell commands?
It will be possible ,but you have to write lengthy code for it.(e.g If you have Network interface you need to use if block for it, so that it gets you the network interface subnetid and then again elseiffor any other resource ).
Azure portal provides a feature called connected device from their we can simply check the devices are connected to the V-net.
As shown here:
Using Powershell CMD if you get the virtual network you can determine the associated resources in the subnet :-

Azure WVD Hostpool - Virtual Network displaying "None available"

I keep encountering an irritating blocker when attempting to create a Host Pool for my project's Windows Virtual Desktop (WVD) in Azure and I'm at my wits end figuring out what could be causing this issue.
My existing resource group contains the following resources (all fully setup and configured):
A VNet
Security Group
Key Vault
All of the above resources can be confirmed via the Portal, Azure Powershell and Az CLI.
However, when attempting to create the Host Pool for the WVD which is the next resource we're seeking to provision manually through the Portal, I get prompted to Add virtual machines and upon selecting the option to add a virtual machine, I'm prompted to complete the Network and security configuration. However, the Virtual network dropdown isn't populated with any list, rather showing as "None available".
The Virtual Network definitely exists and I can't understand why the dropdown list continues to be empty. I've deleted and recreated the entire resource group on a number of occasions but all to no avail. Any advice or suggestions on how to get past this issue would be much appreciated.
Thank you for updating your solution. I face exact same problem and follow your guidance and find that my VNET is in a different region v.s. the host pool.
Originally I can not find the drop down item in the virtual network either, my workaround is to create a VNET in the same region on host pool and now I can select it.
Managed to establish what the issue was. It was the selected "Virtual machine location" value that was not allowing me to see the target VNet in the "Virtual network" dropdown list.
By default, Azure was populating the Virtual machine location field with the name of a region where my VNets didn't exist. Once I'd spotted this and switched it to the correct Region, the Virtual network dropdown list further below was populated as expected.

How Can I Recursively Compare Azure Resource Groups?

I have one resource group that I set up with the portal and another that I tried to configure the same way using Terraform.
Each group contains
Application Gateway with Web App Firewall
Virtual networks and subnets
VMs and associated storage
Public IPs, NSGs, NIC etc
Is there a way for me to compare the two sets of configurations?
For you, I assume you want to create the same resources with the same configurations in another group through Terraform. On my side, there are not many things you need to care about. Just according to the configuration of the resources to create the terraform script.
each resource region
the public IP and the NIC allocation method
NSG rules
vnet and the subnet address prefix
application gateway properties and the rules
The above points are that I think you need to care about. And the properties of the resources in Terraform also need to according to. I think there is no other way to compare two sets of configurations. If you really want, you can compare the template of each group when you create them. The group template shows below:
No, i dont think there is a reasonable straight forward way of doing this, you can create a powershell script that would get resources in each resource group and then try and compare properties, but its hard to give some sort of estimation how accurate it would be, there is a Compare-Object cmdlet in powershell, which might help you with that.

Azure, creating a new virtual machine, it needs to allow chose the NetworkInterface

As creating a new Virtual Machine in Azure, sure on Resource Manager mode, It allows to configure new/existing plenty of parameters:
Storage account
Virtual Network
Public IP Address
Network security group
Diagnostic Storage Account
and so on ...
But not the Network Interface, creating then a random one with a name like MyVMname666 or any other 3 digits random number
Just: WHY?
Why not allow the user to configure it manually, or chose between existing
I can raise a new environment with all perfect defined resource names, except the Network interface ;-(
You can use PowerShell and\or Cli to achieve that, but this is not the place to raise this question. there's the feedback portal for ideas like that.
As for the PowerShell, here's the way to do that.

any way to quickly list azure classic VMs that includes their machine type via an sdk or http api?

I haven't found any azure management service endpoint that lists virtual machines and includes the instance/machine type in the output.
The only method I have found to get the machine type is by getting an individual machine rather than a list. e.g. via the node cli azure resource show -g my-group-name -n my-resource-name -r "Microsoft.ClassicCompute/virtualMachines" -o "2015-10-01" --json This works, but it is incredibly slow to fetch just a single resource. No way that can scale to reporting on hundreds of VMs in a reasonable manner.
What am I missing? this seems crazy.
Using the Azure Resource Manager, you can get a list of Resource Groups:
https://management.azure.com/subscriptions/<subscriptionID>/resourceGroups?api-version=2014-04-01
and then iterate through the resource groups to get a list of Microsoft.ClassicCompute VMs:
https://management.azure.com/subscriptions/<subscriptionID>/resourceGroups/<yourResourceGroup>/providers/Microsoft.ClassicCompute/virtualMachines?api-version=2015-06-01

Resources