public InProgressOperation(ResourceGroup resourceGroup, DeploymentType deploymentType) { this.ResourceGroup = resourceGroup; this.DeploymentType = deploymentType; this._tokenSource = new CancellationTokenSource(); this.Task = Task.Delay(Timeout.Infinite, this._tokenSource.Token); }
public static async Task<ResourceGroup> CreateResourceGroup(string subscriptionId, string region) { var guid = Guid.NewGuid().ToString(); var resourceGroup = new ResourceGroup(subscriptionId, string.Join(Constants.TryResourceGroupSeparator, Constants.TryResourceGroupPrefix, region.Replace(" ", Constants.TryResourceGroupSeparator), guid)) { Tags = new Dictionary<string, string> { { Constants.StartTime, DateTime.UtcNow.ToString("u") }, { Constants.IsRbacEnabled, false.ToString() }, { Constants.GeoRegion, region } } }; var csmResponse = await csmClient.HttpInvoke(HttpMethod.Put, CsmTemplates.ResourceGroup.Bind(resourceGroup), new { tags = resourceGroup.Tags, properties = new { }, location = region }); csmResponse.EnsureSuccessStatusCode(); return resourceGroup; }
// ARM // ARM private async Task DeleteResourceGroup(ResourceGroup resourceGroup) { SimpleTrace.Diagnostics.Information("Deleting expired resourceGroup {resourceGroupId}", resourceGroup.CsmId); if (resourceGroup.AppService == AppService.Web) { await LogActiveUsageStatistics(resourceGroup); } HostingEnvironment.QueueBackgroundWorkItem(_ => _backgroundQueueManager.DeleteResourceGroup(resourceGroup)); }
// ARM private async Task LogActiveUsageStatistics(ResourceGroup resourceGroup) { try { var site = resourceGroup.Sites.First(); var credentials = new NetworkCredential(site.PublishingUserName, site.PublishingPassword); var zipManager = new RemoteZipManager(site.ScmUrl + "zip/", credentials); using (var httpContentStream = await zipManager.GetZipFileStreamAsync("LogFiles/http/RawLogs")) { await StorageHelper.UploadBlob(resourceGroup.ResourceUniqueId, httpContentStream); } await StorageHelper.AddQueueMessage(new { BlobName = resourceGroup.ResourceUniqueId }); } catch { } }
public static void ValidateCsmResourceGroup(ResourceGroup resourceGroup) { }