private async Task RestoreIt(string token) { var url = _config.RestoreApi.Format(_config.SubscriptionId, _config.ResourceGroupName, _context.ServiceName, _config.ApiVersion); var body = new BackupInfo { AccessKey = _config.AccessKey, BackupName = _context.BackupName, ContainerName = _config.ContainerName, StorageAccount = _config.StorageAccount }; try { var res = await url.WithOAuthBearerToken(token).PostJsonAsync(body).ConfigureAwait(false); var resMessage = await res.Content.ReadAsStringAsync().ConfigureAwait(false); _logger.LogInformation("Restore trigger sucessfuly completed. Please note it may take up to 30 or more minutes to complete"); _logger.LogInformation("You can close the app now."); } catch (Exception ex) { _logger.LogError(ex, "Could not trigger a restore."); } }
private async Task CreateBackup(string token) { var url = _config.BackupApi.Format(_config.SubscriptionId, _config.ResourceGroupName, _config.ServiceName, _config.ApiVersion); var body = new BackupInfo { AccessKey = _config.AccessKey, BackupName = $"{_config.ServiceName}_{DateTime.Now.ToString(dateFormat, CultureInfo.InvariantCulture)}.blob", ContainerName = _config.ContainerName, StorageAccount = _config.StorageAccount }; try { var res = await url.WithOAuthBearerToken(token).PostJsonAsync(body).ConfigureAwait(false); var resMessage = await res.Content.ReadAsStringAsync().ConfigureAwait(false); _logger.LogInformation("Backup trigger sucessfuly completed. Please note it takes couple of minutes to complete."); } catch (Exception ex) { _logger.LogError(ex, "Could not create a backup."); } }