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

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

Related

Keep specific log analytics workspace and Remove any other

I have loads of migrated VMs which have got multiple Azure log analytic workspaces tagged/configured at VM level.
So what if I don't want to delete the LAW IDs configured at VM level (not in Azure portal) by giving the definite list as I don't have a pre-known list of those multiple LAW rather just keep needed one by matching it within list and delete rest. I don't find an option to do so in documentation! Only looking for doing this via powershell script
Thanks in advance!
By using a powershell script on Azure Doc. we are able to delete multiple LAW Ids by enlisting them, but then there are so many Vms and tenants that it is not possible to keep doing it like this.
After reproducing from my end, I could able to achieve your requirement using the below script.
$AllLaws=Get-AzureRmOperationalInsightsWorkspace
$Requiredlaws = "<Your_Required_LAW_1>","<Your_Required_LAW_2>"...
foreach($law in $AllLaws)
{
if($law.Name -NotIn $Requiredlaws)
{
Remove-AzOperationalInsightsWorkspace -ResourceGroupName $law.ResourceGroupName -Name $law.Name
}
}
RESULTS:

Azure Calculator API: How do I get expected network bandwidth metrics?

I am working on building out a report that will help team members make decisions on VM types for Azure deployments. One of the data points I'm being asked to provide is the "Expected network bandwidth" for each type. (See this link for an example of the metric)
In the Virtual Machine Sizes REST API, there is no mention of expected network bandwidth. Where can I get that information? Is there another API that I can hit to get more detailed information about virtual machine SKUs?
The information that is returned from that API looks like this:
{
"name": "Standard_B1ls",
"numberOfCores": 1,
"osDiskSizeInMB": 1047552,
"resourceDiskSizeInMB": 4096,
"memoryInMB": 512,
"maxDataDiskCount": 2
}
You can use resource sku list rest api to get more details on the sku .
GET https://management.azure.com/subscriptions/{subscription-id}/providers/Microsoft.Compute/skus?api-version=2019-04-01
I tested the above and I could see more details like IOPS and No. of Nic's etc , but there is no expected network bandwidth.
I tried to check with az cli as well , but it seems its not possible to get expected bandwidth from anywhere.
az vm list-skus -l eastus2 --size Standard_A1_v2
Reference:
Resource Skus - List - REST API (Azure Compute) | Microsoft Docs
az vm | Microsoft Docs

Work on kubernetes with two accounts in PowerShell with Azure

I have two separate Azure accounts.
One for each project in which I am involved, these accounts are totally independent, that is, they do not share any type of resource and do not have the same domain. They are from two totally different companies.
I find that both accounts respond to me at the time of login from PowerShell and I can access those resources.
Both work with Kubernetes (kubectl) but only one of the two accounts is shown. Whatever you do always shows the content of co-owners of one and not the other.
I have the Azure CLI (v.2.0.76) and the PS version is (5.1)
someone know how to I can do?
EDIT with pictures -
Although the account is default, I am not able to access the kubernetes of the same
PS Default Account
Services from the other account..not the default account
services from other cluster
I just found the solution.
When we access from PS with Az Login and select the account, it allows us to access all the resources of that account (the one that is predetermined)
What I have done is basically see the
kubectl config view
This returns the result of all the clusters that it finds with its context. The next thing we have to do is tell kubectl what CONTEXT we want to work with in the following way:
kubectl config use-context "CONTEXT NAME"
And thats it.

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

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.

Azure manage compute API is failing with InvalidAPIVersion error

I am trying to use Azure resource manager and Azure Compute Management APIs to get list of virtual machines in a resource group and all of virtual machine properties. It's failing with InvalidAPIVersion error even though I have updated to latest version. As per the error it expects older version no but i don't see any old library with such a version. Can someone please suggest what am I missing?
VirtualMachineGetResponse vm = m_computeClient.VirtualMachines.Get("/subscriptions/1f94c869-####-####-####-055e8ae15be3/resourceGroups/TestGroup", "TestMachine");
m_computeClint is an object of ComputeManagementClient class in name space Microsoft.Azure.Management.Compute
Is this because resource provider is Microsoft.ClassicCompute?
Error message:
InvalidApiVersionParameter: The api-version '2015-05-01-preview' is invalid. The supported versions are '2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'.
If you're using the resource group management api, you're definitely going to get an invalidapiversionparameter using ClassicCompute. The resource management compute provider is "Microsoft.Compute"; ClassicCompute exists only to view VMs that were already created using the service management API.
Right now, you should keep the two APIs and resources separate. Did you create the VM using the preview portal (portal.azure.com) or using PowerShell? If the former, it has almost (but not quite) converted over to using the resource management api. Try following these steps: https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-deploy/.
Hope that helps.

Resources