Azure Scaleset - is there a Get-AzureRmVmssDiagnosticsExtension - azure

Is there a Get-AzureRmVmssDiagnosticsExtension. How do I get if a scale set has diagnostics enabled and what storage it is using.

As far as I know, there is no command to get the storage account directly.
But we can use PowerShell to the information of vmss, like this:
PS C:\Users> get-azurermvmss -ResourceGroupName vmss -VMScaleSetName vmss

Related

Change the boot diagnostic storage account of azure virtual machine

I have enabled a diagnostic storage account for my virtual machine. Now I want to change the diagnostic storage account. How do I do it in portal / PowerShell?
I can see that we have a cmdlet - "Set-AzureRmVMBootDiagnostics", however, this is not updating the diagnostic storage account to a new one.
In specific:
My current diagnostic storage is "ibmngeus2" and I would like to change to "sqlbackupacct".
In the Azure portal, you should be able to click on the boot diagnostics section of the virtual machine, and then click the settings, and then click the storage account section to change the storage account. Keep in mind that the new storage account you want to use must be in the same subscription and location or it will not show up as one you can choose.
I got the settings under the "Boot Diagnostic" option under the Virtual machine pane.
In PowerShell (with the now-deprecated AzureRM module), you can do this:
Get-AzureRmVM <Stuff to filter the VMs you want go here> | Set-AzureRmVMBootDiagnostics -Enable -ResourceGroupName <storage-account-rg> -StorageAccountName <storage-account-name> | Update-AzureRmVM
This will get the VM objects, change the setting and apply the change.
Example, to update all VMs' diag storage account to bucket in RG mygroup:
Get-AzureRmVM | Set-AzureRmVMBootDiagnostics -Enable -ResourceGroupName mygroup -StorageAccountName bucket | Update-AzureRmVM
(You probably want to filter more...)
For the new Az module, the commands would change to: (same warnings as above will apply)
Get-AzVM <Stuff to filter the VMs you want go here> | Set-AzVMBootDiagnostic -Enable -ResourceGroupName <storage-account-rg> -StorageAccountName <storage-account-name> | Update-AzVM
Get-AzVM | Set-AzVMBootDiagnostic -Enable -ResourceGroupName mygroup -StorageAccountName bucket | Update-AzVM
(There is a deprecation warning for the plural version of the command - this uses the new name, but the warning still shows)

Azure Virtual Machine Scale set - Check if stopped or started via Powershell

Azure has a number of Powershell cmdlets to work with virtual machine scale sets, such as Get-AzureRmVmss. However, I haven't found anything that enables me to determine if a vm scale set is stopped or started. Does anyone know this is possible within Powershell? I suspect it has to be but I'm at a loss to find the support.
Use below PowerShell Cmdlet to get the Status of the Virtual Machine in the Virtual Machine Scale Set(VMSS)
(Get-AzureRmVmssVM -ResourceGroupName {ResourceGroup-Name} -VMScaleSetName {VMSS-Name} -InstanceView -InstanceId "{Instance-ID}").Statuses
Example: (Get-AzureRmVmssVM -ResourceGroupName vmss-rg -VMScaleSetName myvmss -InstanceView -InstanceId "1").Statuses

migrating existing Azure VMs to Azure Premium Storage

i am having two VM'S which is under domain running erp application and database server. Both vm are in Standard D12 v2 (4 cores, 28 GB memory)template.
Now we need to move these VM's into premium disk. So How can i migrate existing Azure VMs to Azure Premium Storage.
I will recommend migrating to Managed Disk and you can migrate existing VMs using standard storage account to Managed Disk and Premium Storage account follow article below.
Migrate existing Azure VMs using standard unmanaged disks to Premium managed disks
We can migrate existing Azure VMs from standard storage account to Premium storage account, but we need to shutdown the VMs.
If we can shutdown the VMs, then we can follow those steps to migrate them:
1.Via Azure portal to create a premium storage account(new).
2.Shutdown Azure VMs, copy VHDs to premium storage account. we can use PowerShell, Azure storage explorer or Azcopy to copy VHDs to new storage account.
3.Just delete Azure VMs and keep the VHDs, Virtual Network, NIC, Public IP address and other settings.
4. Use new storage account to create new VMs, when we create new VMs, in the configure page, we select original Vnet and NIC to it.
5. After it complete, try to login those VMs and test
erp application, make sure that the VMs to run properly, then delete original VHDs and storage account.
Note:
When we use VHDs from new storage account to create VMs, we need to select VM disk type to SSD.
===========================================
Update:
1. stop Azure VM and delete the VM via Azure portal.
2. use Azcopy(Microsoft Azure storage command line) to copy VHD to new Azure premium storage account:
AzCopy /Source:https://vmdisks416.blob.core.windows.net/vhds /Dest:https://jasondisk999.blob.core.windows.net/vhds /SourceKey:key /DestKey:key /Pattern:jasonvm20170519131021.vhd
3. Use PowerShell to create new Azure VM:
PS C:\Users> $rgname = "vm"
PS C:\Users> $loc = "eastus"
PS C:\Users> $vmsize = "Standard_DS1_v2"
PS C:\Users> $vmname = "jason-newtest2"
PS C:\Users> $vm = New-AzureRmVMConfig -VMName $vmname -VMSize $vmsize
PS C:\Users> $nic = Get-AzureRmNetworkInterface -Name "jasonvm422" -ResourceGroupName $rgname
PS C:\Users> $nicId = $nic.Id
PS C:\Users> $vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nicId
PS C:\Users> $osDiskName = "jason-newtest"
PS C:\Users> $osDiskVhdUri = "https://jasondisk999.blob.core.windows.net/vhds/jasonvm20170519131021.vhd"
PS C:\Users> $vm = Set-AzureRmVMOSDisk -VM $vm -VhdUri $osDiskVhdUri -name $osDiskName -CreateOption attach -Linux
PS C:\Users> New-AzureRmVM -ResourceGroupName $rgname -Location $loc -VM $vm
WARNING: Since the VM is created using premium storage, existing standard storage account, vmdiag614, is used for boot diagnostics.
RequestId IsSuccessStatusCode StatusCode ReasonPhrase
--------- ------------------- ---------- ------------
True OK OK

Move a Microsoft Azure VM to a Different Subnet Within a vNet

Can't we Move a Microsoft Azure VM to a Different Subnet Within a vNet using the azure new portal or the azure classic portal ? if not possible through portal then how to do so ?then how to edit the properties of a VM after creation, like moving to a different subnet,, etc.,?
It is possible through the new portal. First I want to ask you if you're using a Classic VM or a Resource manager VM. If you're using the last one you can easily switch between subnets by changing the configuration settings.
go to your network interface > Ip configurations and click on the Nic name (see picture below)
A new tab will open and you can change the Subnet of the nic.
If your vm is a classic one, moving it to different vNet is very easy using azure powershell cmdlets. Here is the code-
$vmName = "xxxxx"
$srcServiceName = "xxxxx"
$newVNet = "xxxxx"
# export vm config file
$workingDir = (Get-Location).Path
$sourceVm = Get-AzureVM –ServiceName $srcServiceName –Name $vmName
$global:vmConfigurationPath = $workingDir + "\exportedVM.xml"
$sourceVm | Export-AzureVM -Path $vmConfigurationPath
# remove vm keeping the vhds and spin new vm using old configuration file but in a new vNet
Remove-azurevm –ServiceName $srcServiceName –Name $vmName
$vmConfig = Import-AzureVM -Path $vmConfigurationPath
New-AzureVM -ServiceName $srcServiceName -VMs $vmConfig -VNetName $newVNet -WaitForBoot
if not possible through portal then how to do so ?then how to edit the properties of a VM after creation, like moving to a different subnet,, etc.,?
It could be done with Powershell. In brief, it contains 3 steps:
Get the VM (NIC) configuration
Edit the VM (NIC) configuration
Update the edited configuration
Note: Moving VMs between different VNET is not supported. To move the VM to another VNET, the only solution for now is re-create the VM with the same vhd file.
Here is a good step-by-step guide:
How to change Subnet and Virtual Network for Azure Virtual Machines (ASM & ARM)

Why does New-AzureReservedIP return ResourceNotFound: No deployments were found?

I have a cloud service that has two VMs in it. I'm trying to follow the steps listed in this article to reserve my cloud service's IP address.
Login-AzureRmAccount -TenantId <my tenant id>
Set-AzureRmContext -SubscriptionId <my subscription id>
New-AzureReservedIP -ReservedIPName myname -Location "Central US" -ServiceName mycloudservicename
I always get this error:
New-AzureReservedIP : ResourceNotFound: No deployments were found.
The VMs were created in the new portal but are classic mode. I'm not sure if that is somehow my problem. I've tried other combinations of cmdlets to add accounts or set subscription but nothing helps.
Any ideas?
I was fighting like 30 minutes with this. I'm not very sure why this was happening but I think was an error selecting the subscription. Last time it worked like this:
Close Azure Power Shell and Open it again.
Listed my subscriptions with: "Get-AzureSubscription" (Make sure you are logged in).
Now I can see the exact Subscription ID and use "Select-AzureSubscription -SubscriptionId XXXXXXXX"
After that the command worked.
New-AzureReservedIP -ReservedIPName "myname" -Location "South Central US" -ServiceName "myservice"
Hope it helps.
If your VMs were created in the new portal, you need to switch to the Resource Manager model, New-AzureReservedIP is only used for the classic portal services, so it prompted ResourceNotFound: No deployments were found error.
There is no AzureReservedIP in Azure RM cmdlets. In the new portal, the IP address is associated to network interface.If you want to set your VMip to be static,run the following command:
$nic=Get-AzureRmNetworkInterface -ResourceGroupName JohTest -Name johtestvm250
$nic.IpConfigurations[0].PrivateIpAllocationMethod="Static"
$nic.IpConfigurations[0].PrivateIpAddress = "10.2.0.4"
Set-AzureRmNetworkInterface -NetworkInterface $nic
If you dont know the networkinterface in your RG, run the command to see:
Get-AzureRmNetworkInterface -ResourceGroupName JohTest
More information here

Resources