Update Windows Azure Endpoint with load balancer probe settings - powershell

I am trying to update the probe settings for a load balanced endpoint in windows azure but facing
"Update-AzureVM : Failed: The server encountered an internal error. Please retry the request."
Since probe settings for endpoints are not accessible through the web GUI I am using the PowerShell cmdlets to achieve this. I have followed the guide here
http://www.windowsazure.com/en-us/manage/windows/common-tasks/how-to-load-balance-virtual-machines/#lbprobes
I have also tried with adding a new endpoint with cmdlet Add-AzureEndpoint and updating a existing endpoint with Set-AzureEndpoint. The commands executed is:
Get-AzureVM -Name "web-server-01" -ServiceName "web-servers" | Add-AzureEndpoint -LBSetName "Web_80" -Name "Web" -Protocol "tcp" -LocalPort 80 -PublicPort 80 -ProbePort 80 -ProbePath "/ping" -ProbeProtocol http | Update-AzureVM
Is there anyone familiar with the problem and has succeeded updating the probe settings or knows how to get more out of the error message generated?

I faced a similar problem when I try to get the endpoints for a VM using:
Get-AzureVM –ServiceName “XXX” –Name “XXX” | Get-AzureEndpoint
Setting the default subscription bevore retrieving the VM solved it:
Set-AzureSubscription -DefaultSubscription XXX
Maybe that helps you too

Related

Issue with service fabric resource manager file deployment (apim.json and apim.parameters)

My requirement is as follows:
I have an web API whose port I have removed from the ServiceManifest.xml file. This is done so that I can implement multiple node multiple calls feature from API management. (i.e. I want to remove dependency on port number)
While deploying API management resource files, I am facing issues while deploying apim.json and apim.parameters.json file.
Following is the exception I am getting always.
"Service activation failed. Please look at the details in Activity Log on the left side. In case you are deploying into VNET please make sure prerequisites are followed as described on https://aka.ms/apiminvnet"
There is nothing in the log files when I am uploading.
I am using following link for the deployment and testing. https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-tutorial-deploy-api-management
I am getting exception in running powershell script
New-AzureRmResourceGroupDeployment -ResourceGroupName $groupname -TemplateFile "$templatepath\apim.json" -TemplateParameterFile "$templatepath\apim.parameters.json" -Verbose

Set site webbindings to localhost-only and then restore them

We need to run smoke tests during our Web Application's deployment script, which is a powershell script. Our site is hosted in IIS, and it normally runs with https on port 443 and requires authentication using OAuth. The smoke tests can't have test accounts, however, so they can't authenticate.
One option we are exploring is to disable authentication for the duration of the smoke tests and run them over http. I would need for our powershell script to do something like this (in pseudocode):
<save current webbindings for Default Web Site>
<set http on port 80 and localhost-only access for Default Web Site>
<execute the smoke tests>
<restore previous webbindings for Default Web Site>
I think that the Set-WebBinding command should be able to do this, but the only example there is this one:
Set-WebBinding -Name 'Default Web Site' -BindingInformation "*:80:" -PropertyName Port -Value 1234
Does this command set localhost-only access? And how do I store the configuration before changing it, and then restore it afterwards?

RabbitMQ failed to start, TCP connection succeeded but Erlang distribution failed

I'm a new one just start to learn and install RabbitMQ on Windows System.
I install Erlang VM and RabbitMQ in custom folder, not default folder (Both of them).
Then I have restarted my computer.
By the way,My Computer name is "NULL"
I cd to the RabbitMQ/sbin folder and use command:
rabbitmqctl status
But the return message is:
Status of node rabbit#NULL ...
Error: unable to perform an operation on node 'rabbit#NULL'.
Please see diagnostics information and suggestions below.
Most common reasons for this are:
Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)
CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server)
Target node is not running
In addition to the diagnostics info below:
See the CLI, clustering and networking guides on http://rabbitmq.com/documentation.html to learn more
Consult server logs on node rabbit#NULL
DIAGNOSTICS
attempted to contact: [rabbit#NULL]
rabbit#NULL:
connected to epmd (port 4369) on NULL
epmd reports node 'rabbit' uses port 25672 for inter-node and CLI tool traffic
TCP connection succeeded but Erlang distribution failed
Authentication failed (rejected by the remote node), please check the Erlang cookie
Current node details:
node name: rabbitmqcli70#NULL
effective user's home directory: C:\Users\Jerry Song
Erlang cookie hash: 51gvGHZpn0gIK86cfiS7vp==
I have try to RESTART RabbitMQ, What I get is:
ERROR: node with name "rabbit" already running on "NULL"
By the way,My Computer name is "NULL"
And I have enable all ports in firewall.
https://groups.google.com/forum/#!topic/rabbitmq-users/a6sqrAUX_Fg
describes the problem where there is a cookie mismatch on a fresh installation of Rabbit MQ. The easy solution on windows is to synchronize the cookies
Also described here: http://www.rabbitmq.com/clustering.html#erlang-cookie
Ensure cookies are synchronized across 1, 2 and Optionally 3 below
%HOMEDRIVE%%HOMEPATH%\.erlang.cookie (usually C:\Users\%USERNAME%\.erlang.cookie for user %USERNAME%) if both the HOMEDRIVE and HOMEPATH environment variables are set
%USERPROFILE%\.erlang.cookie (usually C:\Users\%USERNAME%\.erlang.cookie) if HOMEDRIVE and HOMEPATH are not both set
For the RabbitMQ Windows service - %USERPROFILE%\.erlang.cookie (usually C:\WINDOWS\system32\config\systemprofile)
The cookie file used by the Windows service account and the user running CLI tools must be synchronized by copying the one from C:\WINDOWS\system32\config\systemprofile folder.
If you are using dedicated drive folder locations for your development tools/software in Windows10(Not the windows default location), one way you can synchronize the erlang cookie as described by https://www.rabbitmq.com/cli.html is by copying the cookie as explained below.
Please note in my case HOMEDRIVE and HOMEPATH environment variables both are not set.
After copying the "C:\Windows\system32\config\systemprofile\.erlang.cookie" to "C:\Users\%USERNAME%\.erlang.cookie" ,
the error "tcp connection succeeded but Erlang distribution failed" is resolved.
Now I am able to use "rabbitmqctl.bat status" command successfully. Hence there is no mandatory need to install in default location to resolve this error as synchronizing cookie will resolve that error.
In my case similar issue (Authentication failed because of Erlang cookies mismatch) solved by copying .erlang.cookie file from Windows system dir - C:\Windows\system32\config\systemprofile\.erlang.cookie to %HOMEDRIVE%%HOMEPATH%\.erlang.cookie (where %HOMEDRIVE% was set to H: and %HOMEPATH% to \ respectively)
Quick setup TODO for Windows, Erlang OTP 24 and RabbitMQ 3.8.19:
Download & Install Erlang [OTP 24] (needs Admin rights) from:
https://www.erlang.org/downloads
set ERLANG_HOME (should point to install dir)
Download & Install recent [3.8.19] RabbitMQ (needs Admin rights) from:
https://github.com/rabbitmq/rabbitmq-server/releases/
Follow: https://www.rabbitmq.com/install-windows.html and/or
https://www.rabbitmq.com/install-windows-manual.html
set RABBITMQ_SERVER (should point to install dir)
update %PATH% by adding: ;%RABBITMQ_SERVER%\sbin
Fix Erlang-cookie issue from above, follow: https://www.rabbitmq.com/cli.html#erlang-cookie
Enable Web UI by running command: %RABBITMQ_SERVER%/sbin/rabbitmq-plugins.bat enable rabbitmq_management
From item #8 (above) got error because of missing file: %USERPROFILEDIR%/AppData/Roaming/RabbitMQ/enabled_plugins -> had to create it and run %RABBITMQ_SERVER%/sbin/rabbitmq-plugins.bat enable rabbitmq_management again!
Run/restart on the way might be required
Finally, login to: http://localhost:15672/ (guest:guest)
, or check by cURL:
curl -i -u guest:guest http://localhost:15672/api/vhosts
should receive response like:
HTTP/1.1 200 OK
cache-control: no-cache
content-length: 186
content-security-policy: script-src 'self' 'unsafe-eval' 'unsafe-inline';
object-src 'self'
content-type: application/json
date: Tue, 13 Jul 2021 11:21:12 GMT
server: Cowboy
vary: accept, accept-encoding, origin
[{"cluster_state":{"rabbit#hostname":"running"},"description":"Default virtual host","metadata":{"description":"Default virtual host","tags":[]},"name":"/","tags":[],"tracing":false}]
P.S. Some useful RabbitMQ CLI commands (copy-paste):
%RABBITMQ_SERVER%/sbin/rabbitmqctl start_app
%RABBITMQ_SERVER%/sbin/rabbitmqctl stop_app
%RABBITMQ_SERVER%/sbin/rabbitmqctl status
P.P.S. UPDATE: great article for this subject: https://www.journaldev.com/11655/spring-rabbitmq
I have reinstalled the RabbitMQ in my computer by using default setup folder
Then checked with the command :
rabbitmqctl status
It works now, not the problem of Erlang VM .(Means Er can install at another folder)
It will cause some problem (like this one) that I couldn't find out now if we don't use the RabbitMQ default setup require folder (C:\Program Files\RabbitMQ Server)
If anyone finds it out, I hope you can tell me why and how to fix.
How I resolved mine
It's mostly caused by cookie mismatch on a fresh installation of Rabbit MQ
follow this 2 steps
1. copy the .erlang.cookie file from C:\Windows\System32\config\systemprofile paste it into
C:\Users\["your user nameusername"] folder
2. run rabbitmq-service.bat stop and rabbitmq-service.bat start
Done it should work now when you run 'rabbitmqctl start_app' good luck.
note if you have more than one user put it in the correct user folder
In Centos.
add ip nodename pair to /etc/hosts on each node.
restart rabbitmq-server service on each slave node.
works for me.
i got error like this, i just stop my rabbitMQ with close port 25672
here syntax for linux:
kill -9 $(lsof -t -i:25672)
Error Images:
Just adding my experience if it helps others down the line.
I wrote a Powershell .ps1 script to install and configure RabbitMQ which would be used as one of the stept to provision a server with Packer.
I wrote the code on a fresh AWS W2016 Server build. It worked fine when run on the box (as administrator, from an admin PS console) but when the same code was moved over to the Packer build server, it would fall over when doing the rabbitmqctl.bat configuration steps via packer, despite both using (as far as I can tell) Administrator to run the scripts.
So this worked on the coding box:
$pathvargs = {cmd.exe /c "rabbitmqctl.bat" add_user Username Password}
Invoke-Command -ScriptBlock $pathvargs
$pathvargs = {cmd.exe /c "rabbitmqctl.bat" set_user_tags User administrator}
Invoke-Command -ScriptBlock $pathvargs
$pathvargs = {cmd.exe /c "rabbitmqctl.bat" set_permissions -p "/" User "^User-.*" ".*" ".*"}
Invoke-Command -ScriptBlock $pathvargs
Write-Host "Did RabbitMQ"
But I had to prelude this with...
copy "C:\Windows\system32\config\systemprofile\.erlang.cookie" "C:\Program Files\RabbitMQ Server\rabbitmq_server-3.7.17\sbin\.erlang.cookie"
copy "C:\Windows\system32\config\systemprofile\.erlang.cookie" $env:userprofile\.erlang.cookie -force
... On the Packer box.
I am guessing there is some context issue going on but I'm using
"winrm_username": "Administrator",
in the Packer builders block, so I thought this would suffice.
TL;DR - Use the Cookie even though it works without it in some instances.
I have encountered the same error after installing Erlang VM and RabbitMQ using the default installation folders in Windows 10. Managed to start the management and access it via HTTP, but status failed with this error.
The cookie was fine in all folders (%HOMEDRIVE%%HOMEPATH%, %USERPROFILE%, C:\WINDOWS\system32\config\systemprofile).
I had to perform a restart the Windows to make it work. After restart it set up something to run at startup + asked permission to make an exception in the firewall.
In my case, the file was at c:\\Windows\.erlang.cookie, just copied it to C:\Users{USERNAME} and all works, thanks to everyone for the hits
Another thing to check after making sure the cookie file is in all the locations.. is to realize that you installed 32 bit Erlang.. not 64..
Happened to me. Removed 32 bit Erlang and Installed 64 and rabbitmqctl status returns expected results.

How to add a Certificate to an azure service fabric cluster vmset

I have a Service Fabric cluster with a vmset based on a key-vault for its secrets. It runs fine, but now I need to add a certificate to the personal stores on the running instances (by preference without doing it manually in RDP). I used powershell to add the certificate to the key-vault, but even after increasing the capacity of vmset the new vm does not has the new certificate.
When I try to "reimage" the existing vm's I get the error
Failed to reimage virtual machine instance 'xxxxxxx'. Error: Virtual
Machine Scale Sets with extension
Microsoft.Azure.ServiceFabric.ServiceFabricNode cannot be reimaged.
So I though I could update the certificate on a virtual machine with the following command
$vm = Add-AzureVMSecret -VM $vm -SourceVaultId $SourceVaultId -CertificateStore $certStore -CertificateUrl $certUrl;
Update-AzureRmVM -ResourceGroupName $resourceGroup -VM $vm
But it seems I'm unable to get an individual vm inside the vmset.
$vm = Get-AzureRmVM -ResourceGroupName $resourceGroupName -Name "xxxxxx"
Get-AzureRmVM : The Resource
'Microsoft.Compute/virtualMachines/xxxxxx' under resource group
'xxxxxxxxxxxxxxx' was not found. StatusCode: 404 ReasonPhrase: Not
Found
Does anyone know how to add a certificate on existing vm's inside a vmset?
And what if I need to update an certificate that is going to expire, seems like I'll need to do something simular.
You can define the certificates to deploy in the ARM template.
Examples here and here.
Relevant node: 'osProfile'.

Associate a Public IP in an Azure Resource Group to a Web App?

I'm playing around with Azure Resource Groups.
I've created a group, and in it, I've created a web app. (This is all just academic and I'll delete it all when I'm done leaning, so I don't mind sharing the data.) The web app is located at http://woodswild.azurewebsites.net, and indeed you can go to that address and it will resolve (although there is nothing there, which is fine for now.)
Then, in the same resource group, I also created a Public IP Address that is static.
That all looks good (I think, anyway). But in the Portal UI, I see that this IP is not associated to anything:
Aaannndd.... I'm having a hard time figuring out how to do that. I created the Public IP from within Azure PowerShell with this command:
New-AzureRmPublicIpAddress -AllocationMethod Static -ResourceGroupName TestRG1 -ReverseFqdn woodswild.centralus.cloudapp.azure.com -Name woodswild.azurewebsites.net -Location "Central US" -DomainNameLabel woodswild
According to this article that explains the New-AzureRmPublicIpAddress command, there is no parameter to declare an association. I'm not seeing a way to do it in the Portal UI, and I can't find any answers via Google.
What I'm hoping / wondering / assuming is that once this association is made, you could put the IP Address in a browser and it would resolve to the same place as http://woodswild.azurewebsites.net.
Any ideas? Thanks!!
It is not actually possible to assign a static IP address to a Web App. This is because the IP address used by Web Apps isn't used exclusively by you, but instead it is the frontend address pool of the load balancers that sit in front of Azure's Web App service.
However Microsoft do assert that any web app that can have a domain name assigned will keep its external incoming address, and external outgoing addresses for the lifetime of the Web App. This applies to Basic, Standard and Premium SKU. (it might apply to Shared too - I'll have to dig out the doc)
You can find your external incoming IP Address with (yeah, basically, ping it and see what DNS gives!)
Resolve-DnsName (Get-AzureRmWebApp `
-ResourceGroupName $ResourceGroupName -Name $Name).EnabledHostNames[0]
and your external outgoing IP Addresses with
(Get-AzureRmWebApp -ResourceGroupName $ResourceGroupName `
-Name $Name).OutboundIpAddresses
It seems I fell at the first hurdle here, and didn't actually read the question. Or at least my brain seems to have read different words than the ones that are there! (I'll leave the wrong answer here because a, it might be useful to someone, b, I'll likely paste it into an actual answer that it fits one day)
The reason this is so confusing is that it is not instantly obvious the process that Azure uses to update resources.
For the majority of existing resource changes that are made in Azure, the process goes something like
Get-something, assign it to a variable.
Change a property of that variable, by assigning some other value.
Write the change to Azure using the Set-something cmdlet.
In the case of assigning an IP address to a VM, this is the code to use
$ipaddr = New-AzureRmPublicIpAddress -Name test1 `
-ResourceGroupName win10 `
-Location westeurope `
-AllocationMethod Static
$nic = Get-AzureRmNetworkInterface -Name $name `
-ResourceGroupName $ResourceGroupName #1
$nic.IpConfigurations[0].PublicIpAddress = $ipaddr #2
Set-AzureRmNetworkInterface -NetworkInterface $nic #3