Author Archive | Jonathan

Send Email when Azure Site Recovery is done or manual step is needed

This post is about sending an email when a Azure Site Recovery (ASR) failover is done or before a manual step in the ASR failover plan. In the example I have used an Azure Automation runbook in the ASR plan to send an email through the service SendGrid. SendGrid can off course be changed to another solution but in my case, I find it easy to use.

If you want to try it, start by creating a SendGrid account in Azure.

Make a note of the username and your password, you will need it later.

Create or import an Azure Automation Runbook that will send the email. This is the Runbook I used: SendEmail Runbook. Read the information in the description of the Runbook to get it working.

In the example Runbook above, an Azure Automation credential is needed. This is how it should look like. Add the username and password from the SendGrid account.

Edit the variables in the Runbook script and publish it.

Go to the Recovery Services vault and add the Runbook to the ASR plan.

0

Clone VMs after ASR Test Failover

If you want to clone a production environment on-prem to Azure and then, for example, test an upgrade or do new development on those servers, here is one way to do it.

My solution is using Azure Site Recovery (ASR) and a PowerShell script. It does not have any impact on the on-prem environment because I am using Test Failover in ASR which is starting the servers on a separate VNet in Azure which is not having any connectivity back on-prem. The Test Failover feature in ASR will make a clone of the on-prem servers in Azure and will not shut them down.

In ASR, as of today, you can only do one Test Failover at the time. This means that if you have done one Test Failover you cannot do another one while the first one is running. Because of this I am using a script in ASR to clone the Test Failover VMs so you can do more than one environment for testing.

Here is how I did it!

1.       First step is to install and configure ASR to replicate the servers that is going to be cloned https://docs.microsoft.com/en-us/azure/site-recovery. When that is done, control that the servers are using Managed Disks. It they are not, change so they do.

2.       Next step is to create an Azure Automation Account and a Runbook for cloning the servers. Here is the script I use: My GitHub. If you are using my script, change the variables to fit your needs.

If you have issues with the script, update the Azure Automation Account modules and import the modules that are needed. Here is a screenshot of the modules I have tested the script with.

3.       When the servers have been replicated with ASR, create an ASR Recovery Plan and add the servers to a Group. Add the earlier created Runbook from Azure Automation as a Recovery Plan post step on the Group with the servers.

When this is done, do a Test Failover to test you Recovery Plan and clone of the servers.

0

Clone VMs in an Azure Resource Group

There are many ways to clone VMs from one Azure Resource Group to another. Here is one example that are using Azure Snapshots. The VMs, to clone, has to belong to the same Azure Region as where the copy should be created and has to use managed disks.

https://github.com/ajonathan/powershell/blob/master/AzureResourceGroupVMsCopy.ps1

To get going with the script, download or copy it from my GitHub account. It works perfect in Azure Cloud Shell for PowerShell  as well as in a Azure Automation Runbook. Just remember to upgrade the modules before running it.

Here is a screenshot from a ready clone from Resource Group myvms-rg.

 

0

Use an Azure Function to add information to Log Analytics

This is an example how to add information from an Azure Function to Log Analytics with C#. I have used the C# code from the Log Analytics documentation and made some changes to fit my needs.

In this example I have chosen to use an http trigger and let the Function to take an json input. The input data is then added into the Log Analytics workspace.

Use an Azure Function to add information to Log Analytics1

Create an Azure Function as a HTTP trigger.

Use an Azure Function to add information to Log Analytics2

Paste the following code and replace the variables LogAnalyticsWorkspaceId and LogAnalyticsWorkspaceKey.

Add test json code in the “Request body” and test the Function by clicking Run.

Use an Azure Function to add information to Log Analytics3

 

0

Pin an Azure Log Analytics search to the Azure Dashboard

In OMS Log Analytics you have, since a couple of weeks ago, had the possibility to do searches with Advanced Analytics, Azure Log Analytics. If you want your queries to show on the Azure Dashboard, you can pin them from inside Azure Log Analytics. In this post, you will see how this is done.

If you have not already done it, share an Azure Dashboard. Click “Share” in the portal and publish is.

Pin an Azure Log Analytics search to the Azure Dashboard1

Then go to Azure Log Search and create your query. When that is done click the pin button marked in red on the screenshot below.

Pin an Azure Log Analytics search to the Azure Dashboard2

When that is done click the pin button marked in red on the screenshot on top. Select the dashboard from the dropdown that shows up. See screenshot below.

Pin an Azure Log Analytics search to the Azure Dashboard3

After pinned, it will show up on the Azure dashboard.

Pin an Azure Log Analytics search to the Azure Dashboard4

0