Use a Custom Automation Account for Azure to Azure Site Recovery Mobility Service Updates
Published Sep 03 2020 08:43 PM 10.7K Views

 

Sr. Customer Engineer Dave Newman here on a short post regarding Azure Site Recovery. Hope this helps you in your day to day cloud journey

 

When replicating Azure VMs from one Azure Region to another for DR purposes, the Mobility Service extension must be added to each protected VM. The extension installation is completed automatically during the “Enable replication” phase of protecting Azure VMs.

 

Periodically, the Azure Site Recovery (ASR) product group will release an Update rollup to include new features, component updates, support improvements and bug fixes. These are not always on a consistent cadence. Typically, there will be at least one each quarter but sometimes, the case of bug fixes there could be more than one. At the time of this writing there have been 8 releases in the last 12 months.

 

The ASR product team has created an automated process that will update the Mobility service extension on Azure VMs that are being replicated. When you establish a new Recovery services vault in your target region and select VMs from the source region to protect, the process of creating new resources on the target side includes the creation of a new Azure automation account that will manage this process. When enabled, the management of the agent versions is handled by a global runbook. A job is created in that Automation account that will initialize daily at midnight to check for the presence of a new agent version. If none is found, then the job completes with no action. If a new version is found, the extension will be updated on the VMs via an Azure Automation runbook to bring the systems into compliance with that latest version.

 

This seems great but there are a few issues. The new Azure Automation account is automatically named and there is no option to specify what that name will be. This will break naming convention. Good governance rules in Azure dictate that wherever possible that a naming convention should be followed. The way the ASR automatically chooses a name is that it takes the first 8 characters of the name of the Recovery service vault, appends a dash (hyphen) and three random alphanumeric characters and then appends the string “-asr-automationaccount”.

If your vault is currently named “AZWUSPRODRSV01”, then the name of your automation account would look something like “AZWUSPRO-a1b-asr-automationaccount”. (the “a1b” character set will be a randomly chosen alphanumeric string.) Not a very governance compliant name.

The second issue is that when creating an Azure Automation account, the default process for authenticating action is to use a “RunAs Account” as defined in the Automation account. This account is an Azure AD Service Principal that is granted a Role Based Access Control (RBAC) role by the creation process. The granted role is Contributor at the Subscription level. That means that the person creating the Automation account needs to have rights in Azure AD to create Azure AD Service Principals and have Owner or User Access Admin RBAC role at the subscription level. Other than User Access Admin, you cannot assign roles with greater privilege than you have been granted. If you are on the DR/Backup team at your organization, you may not have those permissions.

 

The question at hand is, how can you create a naming convention compliant Azure automation account and tell ASR to use that Automation account for the process of updating the Mobility service extension on protected Azure VMs?

 

Step one in this is to ensure that a naming convention compliant Azure automation account exists in the same location and resource group as your recovery services vault on the target side. The creation of an Automation account often requires coordination between the Identity team and the Azure team. As mentioned previously, the person creating this Azure resource needs to have the Owner RBAC role defined at the Subscription level.  As a person on the DR/Backup Team you may need to work with someone else who has the appropriate permissions to have this resource created. The creation of the Azure AD Service Principal account is something that could be achieved by temporarily granting the built-in Azure AD role of Application Administrator or Application Developer to the user creating the Automation account. A tutorial for the creation of an Automation account can be found here.

 

Once the Automation account exists, the recovery service vault in the target region needs to be configured to use that account. This can either be done at the instantiation of the vault or can be done to an existing vault. Both methods will be shown.

 

If you are building out your recovery services vault for the first time for Azure to Azure DR replication, you can follow the normal steps as outlined in this tutorial. Before you complete the tutorial, stop at the end of the Configure replication settings section. Do not click the Create target resources button just yet. The tutorial shows how you can customize the process so that you can use naming convention conforming target objects. There is another option visible on that blade that the tutorial does not cover. At the bottom of the blade there is an option for Extension settings with a [+] Show details link.

 

configuresettings.jpg

 

As you can see, it indicates that extension updates are being managed for you. But this is where it wants to do the collection of actions as mentioned earlier in this document that might fail because of permissions. If you open the Extension settings, you will see that there are a few options. You have the option to turn the process off and manage updates manually if you wish. This avoids the need for an Automation account but adds the manual effort of keeping the VMs updated as new versions become available.

 

extensionsettings.jpg

 

The other box allows you to choose a specific, pre-existing, naming convention compliant Automation account.

 

automationaccount.jpg

 

Once this has been defined you can Create target resources and the system will not attempt to create resources that do not line up with your well-defined Azure governance.

 

If you have already configured replication for VMs and have seen the process of creating that Automation account fail because of lack of permissions, we will now show how to resolve that issue.

 

For an existing recovery services vault that you want to either establish or reconfigure, you will need to navigate to the Manage section in the left side menu of your vault and choose the Site Recovery infrastructure option.

 

asrinfra.jpg

 

From the Site Recovery infrastructure blade, choose Extension update settings. This allows you to toggle on and off the automatic management of the extension updates. It also indicates the name of the Automation account being used if this function is turned on.

 

extensionupdate.jpg

 

 

If the toggle is set to off because the automation account failed to create, and if a new automation account has already been created and is available in the same resource group and in the same Azure location as the vault, that automation account will display as the account the system wants to use. If that is the case, then all you need to do to resolve this issue is to flip this switch to On.

This document has shown how can you create a naming convention compliant Azure automation account and tell ASR to use that Automation account for the process of updating the Mobility service extension on protected Azure VMs.

 

The ask that I have heard many times on this issue up updating ASR is – can I do this for my on-premises to Azure VMware systems that have the Mobility Service agent installed. The short answer is that there is no automated process available from the ASR product team currently, but it is something on the product roadmap. :smile:

 

Hope this helps you in your cloud journey for protecting your Azure VMs. 

 

 

 

9 Comments
Copper Contributor

Good Info! Is there a way to manage multiple vaults with a single automation account?

@cgoenka  There is a requirement that the automation account be in the same region and resource group as the vault. If you have multiple vaults in the same region and in the same resource group then this could be possible but usually the need for multiple vaults is related to being in different regions. I have not tested this but it should work. 

Copper Contributor

Dave, I am currently working in an environment that requires the strictest least-privilege for that automation account.

Is there a reference on the minimum required Roles for the ASR update automation account Run-as account?  Many thanks!

@mikewo-dc  - sorry for the late reply. 

https://docs.microsoft.com/en-us/azure/automation/manage-runas-account#limit-run-as-account-permissi... 

This doc shows how to limit the permissions assigned to a RunAsAccount in Azure automation. There is a built-in RBAC role called Site Recovery Contributor which should provide you with the detailed list of permissions to choose from. 

https://docs.microsoft.com/en-us/azure/automation/manage-runas-account#limit-run-as-account-permissi...

 

Copper Contributor

Hi Dave not a problem at all, thanks for the reply. My colleague did find this page ( https://docs.microsoft.com/en-us/azure/site-recovery/site-recovery-role-based-linked-access-control  ) which describes all the permissions needed for Site Recovery management (e.g. Site Recovery Contributor) and also for enabling Virtual Machine replication (e.g. Virtual Machine Contributor is recommended). We guess the RunAsAccount that updates the SiteRecovery-Windows extension probably needs only a subset of these, but Site Recovery Contributor and Virtual Machine Contributor would seem to be sufficient?

@mikewo-dc  - yes - you would need the Site Recovery Contributor to make the change within ASR and the VM Contributor to trigger the extension update. I have not tested this but it should work that way. 

Copper Contributor

@Dave Newman (PFE) Are there any provisions to below scenarios

a) usage of an common automation account in another subscription such as Management to manage multiple recovery vaults in Spoke subscriptions. I tried it via ARM templates but doesnt permit to. 

 

b) as Microsoft encourages more of Managed Identity these days, is this runbook available via Managed Identity. 

can below snippet in replicationprotectioncontainermappings used to update ASR agents via automation accounts of choice and authentication type of chosen ? 

 

https://docs.microsoft.com/en-us/azure/templates/microsoft.recoveryservices/vaults/replicationfabric...

 

Copper Contributor

Hi All,
please provide the solution to update the ASR agent version as we have multiple subscriptions and in that have Multiple Vaults in different RG's.

till now we are working manual process to update the agent once in a month but we are planning to update the agent via automation account on Schedule time.
Please let us know how do we solve this problem.

 

Thanks,

Rajesh sura 

@Rajeshsura 

You can use PowerShell to update the agent versions on each guest. 

Manage the Mobility agent for VMware/physical servers with Azure Site Recovery - Azure Site Recovery...

 

Version history
Last update:
‎Sep 04 2020 06:28 AM
Updated by: