private async Task DeployRepository(AssetRepository repository)
        {
            try
            {
                using (var client = await _clientProvider.CreateResourceManagementClient(repository.SubscriptionId))
                {
                    await client.ResourceGroups.CreateOrUpdateAsync(repository.ResourceGroupName,
                                                                    new ResourceGroup { Location = repository.Subnet.Location });

                    var templateParams = repository.GetTemplateParameters();

                    var properties = new Microsoft.Azure.Management.ResourceManager.Models.Deployment
                    {
                        Properties = new DeploymentProperties
                        {
                            Template   = await _templateProvider.GetTemplate(repository.GetTemplateName()),
                            Parameters = _templateProvider.GetParameters(templateParams),
                            Mode       = DeploymentMode.Incremental
                        }
                    };

                    // Start the ARM deployment
                    await client.Deployments.BeginCreateOrUpdateAsync(
                        repository.Deployment.ResourceGroupName,
                        repository.Deployment.DeploymentName,
                        properties);

                    // TODO re-enable below for background monitoring.
                    // Queue a request for the background host to monitor the deployment
                    // and update the state and IP address when it's done.
                    //await _deploymentQueue.Add(new ActiveDeployment
                    //{
                    //    FileServerName = repository.Name,
                    //    StartTime = DateTime.UtcNow,
                    //});

                    repository.State      = StorageState.Creating;
                    repository.InProgress = false;

                    await UpdateRepository(repository);
                }
            }
            catch (CloudException ex)
            {
                _logger.LogError(ex, $"Failed to deploy storage server: {ex.Message}.");
                throw;
            }
        }