Reserving static IP for existing Azure Virtual Machine - powershell

I have created 3 virtual machines which are already in operation and I forgot to first assign a static IP at time of creation. I am now encountering some issues when I am trying to do this.
I have created a reserved IP using the following powershell:
New-AzureReservedIP “dmz-live” –Label “be-dmz-ip” –Location “North Europe”
Following this post http://prmdbaora.blogspot.in/2015/06/normal-0-false-false-false-en-us-x-none.html I tried to delete the VM and reassign but when I use the following code:
New-AzureVMConfig -Name "be-dmz" -InstanceSize "Standard_D11" –ImageName "be-dmz-be-dmz-0-201508100952090393" | New-AzureVM -ServiceName "be-dmz" –ReservedIPName " be-dmz-ip " -Location "CloudVNET”
I am getting an error:
New-AzureVMConfig : Must specify MediaLocation or set a current storage account using Set-AzureSubscription.
At line:1 char:1
+ New-AzureVMConfig -Name "be-dmz" -InstanceSize "Standard_D11" -ImageName "be-dmz ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureVMConfig], ArgumentException
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.NewAzure
VMConfigCommand
I have confirmed that the name of the disk is correct, after deleting the cloud service this disk was present but when I tried to run the command it deleted the disk and it is no longer showing in the list of disks
I want to add these machines to a virtual network called "CloudVNET". Can anyone give me a pointer as to what I am doing wrong here please and how I can go about assigned these reserved IPs to the machines

Related

Vsphere Invoke-StartVMPower return error - Get-VM return VM info

This is a VM I created using Terraform
When I run the command Get-VM "VMNAME" it works without a problem and it returns the vm info, but when i run Invoke-GetVmPower -Vm "test_machine_vm_01_output" it return the following error
Invoke-vSphereApiClient : InvocationException: [NOT_FOUND]
Virtual machine with identifier 'test_machine_vm_01_output:UUID' does not exist.
The object 'vim.ManagedEntity:test_machine_vm_01_output' has already been deleted or has not been completely created
---> System.Net.WebException: The remote server returned an error: (404) Not Found.
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.GetResponse(WebRequest request)
at Microsoft.PowerShell.Commands.WebRequestPSCmdlet.ProcessRecord()
--- End of inner exception stack trace ---
At C:\Program Files\WindowsPowerShell\Modules\VMware.Sdk.vSphere.vCenter.Vm\1.0.110.20624081\Api\PowerApi.ps1:507
char:33
+ $invokeResult = Invoke-vSphereApiClient #invokeParams
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-vSphereApiClient
I can start the VM without any issue if i do it from Vcenter
The OS is RHEL7 not windows
https://developer.vmware.com/apis/vsphere-automation/latest/vcenter/api/vcenter/vm/vm/power/get/
String
vm
Virtual machine identifier. The parameter must be an identifier for the resource type: VirtualMachine.
maybe it will work:
$UUID = (Get-View (get-vm VMname).id).config.UUID
Invoke-GetVmPower -Vm $UUID

Add Reserved IP to existing VM on azure

I have resource group "cbp.resourcegroup.neu" both my reserved IP and VM are in the same resource group
my reserved ip name is CBPIP-Dev-NEU
service name for my machine VM is testmachine which i have taken from as first part of DNS name "testmachine.northeurope.cloudapp.azure.com"
when i am running the following command to add reserved ip to VM
Set-AzureReservedIPAssociation -ReservedIPName Group cbp.resourcegroup.neu
CBPIP-Dev-NEU -ServiceName portrtestmachine
I am getting the following error.
Set-AzureReservedIPAssociation : Cannot validate argument on parameter
'Slot'. The argument "CBPIP-Dev-NEU" does not belong to the set
"Staging,Production" specified by the ValidateSet attribute. Supply an
argument that is in
the set and then try the command again.
At line:1 char:76
+ ... ion -ReservedIPName Group cbp.resourcegroup.neu CBPIP-Dev-NEU -Servic
...
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Set-AzureReservedIPAssociation], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.SetAzureReservedIPAssociationCmdlet
IS there anything i am missing in my command . I using powershell to do that.
Group cbp.resourcegroup.neu CBPIP-Dev-NEU
The spaces make the command think you are using positional paramters, so "CBPIP-Dev-NEU" is being passed to the -Slot parameter, for which that is not a valid value.
Try this instead
Set-AzureReservedIPAssociation -ReservedIPName "CBPIP-Dev-NEU" -ServiceName "portrtestmachine"
Azure reserved IP can only be assigned to a deployed PRODUCTION instance.
But that's useless, cause CloudServices already have static IP.
We should check the cloud service, make sure there is no static Public IP address.

Issue with setting up StorageAccountname while starting Azure machine through Powershell

I am trying to install and configure Azure Powershell and surprisingly I am facing issue with setting up of StorageAccountName parameter.
I have my vm setup on my enterprise account with resource group name as "RG-1" and storage account names as rg13675 and rg16461. I found these storage account names after drilling down to my resource group.
On running command,
Set-AzureRmCurrentStorageAccount –ResourceGroupName “RG-1” –StorageAccountName “rg16461"
My powershell throws up error:
Set-AzureRmCurrentStorageAccount : The Resource 'Microsoft.Storage/storageAccounts/rg16461' under resource group 'RG-1' was not found.
At line:1 char:1
+ Set-AzureRmCurrentStorageAccount –ResourceGroupName “RG-1” –StorageAc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzureRmCurrentStorageAccount], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Management.Storage.SetAzureRmCurrentStorageAccount
The reason you're getting this error is because your storage account is a classic storage account (from the screenshot you shared) while the cmdlet expects a resource manager (ARM) storage account.
Please create a new storage account using Resource Manager deployment option and try to use that account's name in your cmdlet. That should fix the error.

Azure PowerShell Add-AlertRule Returns Bad Request when using CpuPercentage on Resource Group

I get an Azure Resource Group and try to add a Metric Alert rule of type CPUPercentage, but it fails with BadRequest.
> $r = Get-AzureRmResourcegroup
WARNING: The output object of this cmdlet will be modified in a future release.
> $a = $r[0]
> Add-AlertRule -Location "West US" -MetricName CpuPercentage -Name CPU98Percent -Operator GreaterThanOrEqual -ResourceGroup $a.ResourceGroupName -ResourceId $a.ResourceId -RuleType Metric -Threshold 98
Add-AlertRule : BadRequest:
At line:1 char:1
+ add-alertrule -Location "West US" -metricName CpuPercentage -Name CPU ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-AlertRule], CloudException
+ FullyQualifiedErrorId : Hyak.Common.CloudException,Microsoft.Azure.Commands.Insights.Alerts.AddAlertRuleCommand
It works fine from the portal. There isn't already an alert with the same name either.
I'm using version 1 of the Azure module and version 1.0.2 of AzureRM.
I was receiving the same error when the alert name was not unique across all databases on the Sql Server. That is, I had multiple databases on the same server and was trying to create a rule named "DTU Percentage", which would fail after the first one was created. Once a unique name ("DTU Percentage DB_NAME") was used, the alerts were created.
Unfortunately, it sounds like you are experiencing another issue. Just thought I would add this answer for anyone searching for similar errors.

Azure VNet Gateway Setup fails for second pair

I am attempting to setup multiple VNet to VNet connections in Azure as described here: https://azure.microsoft.com/en-us/documentation/articles/virtual-networks-configure-vnet-to-vnet-connection/
I have 4 VNets
VNet-North
VNet-South
VNet-East
VNet-West
I have been trying to setup a star topology with a Domain Controller in the center like this:
I have successfully setup VNet-North to VNet-South in both directions.
When I try to connect VNet-North to VNet-East using this PoewerShell command:
PS C:\> Set-AzureVNetGatewayKey -VNetName VNet-North -LocalNetworkSiteName VNet-East -SharedKey A1b2C3D4
It returns success
But when I try:
PS C:\> Set-AzureVNetGatewayKey -VNetName VNet-East -LocalNetworkSiteName VNet-North -SharedKey A1b2C3D4
Set-AzureVNetGatewayKey : BadRequest: The specified local network site name 'VNet-North' is not valid or could not be found.
At line:1 char:1
+ Set-AzureVNetGatewayKey -LocalNetworkSiteName VNet-North -SharedKey AaBaCaDa -VNetN ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Set-AzureVNetGatewayKey], CloudException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.SetAzureVNetGatewayKey
Is a star topology possible?
Had the same problem, resolved by issuing Reset-AzureVNetGateway -VNetName "Name" against all parties having problem. This command will temporarily drop all connections on given VPN gateway, please use it with caution.