public async Task <IActionResult> Get(String requestId) { var table = await ResourceCreateStatusesTable.CreateAsync(requestId); // Creates response model instance and return. // return(Ok(PollingResponse.From(await table.GetStatusesAsync()))); }
public ResourceCreateProgressReport(ResourceCreateStatusesTable statusTable) { this.statusTable = statusTable; }
/// <summary> /// Handle a fluent request from the REST endpoint. /// </summary> /// <param name="requestId">the request id</param> /// <param name="fluentRequestModel">the fluent request</param> /// <param name="cancellationToken">task cancellation token</param> /// <returns>task representing the request handling</returns> private async Task HandleRequestAsync(string requestId, FluentRequestModel fluentRequestModel, CancellationToken cancellationToken = default(CancellationToken)) { IAzure azure = GetAzure(); var progressReport = new ResourceCreateProgressReport(await ResourceCreateStatusesTable.CreateAsync(requestId, cancellationToken)); Dictionary <string, List <dynamic> > rootCreatablesDict = new Dictionary <string, List <dynamic> >(); try { await fluentRequestModel.ValidateAndResolveAsync(azure, fluentRequestModel, "", new DefaultGroupableModel(azure), cancellationToken); rootCreatablesDict = fluentRequestModel.ResolveRootCreatables(azure); } catch (Exception exception) { await progressReport.FailedAsync(FailureRowKey, null, "Error", exception, cancellationToken); return; } foreach (var rootCreatableDictEntry in rootCreatablesDict) { var resourceType = rootCreatableDictEntry.Key; foreach (var rootCreatable in rootCreatableDictEntry.Value) { switch (resourceType) { case ResourceCollectionType.ResourceGroups: await InvokeCreateIngoreErrorAsync((ICreatable <IResourceGroup>) rootCreatable, progressReport, cancellationToken); break; case ResourceCollectionType.PublicIPAddresses: await InvokeCreateIngoreErrorAsync((ICreatable <IPublicIPAddress>) rootCreatable, progressReport, cancellationToken); break; case ResourceCollectionType.Networks: await InvokeCreateIngoreErrorAsync((ICreatable <INetwork>) rootCreatable, progressReport, cancellationToken); break; case ResourceCollectionType.NetworkSecurityGroups: await InvokeCreateIngoreErrorAsync((ICreatable <INetworkSecurityGroup>) rootCreatable, progressReport, cancellationToken); break; case ResourceCollectionType.NetworkInterfaces: await InvokeCreateIngoreErrorAsync((ICreatable <INetworkInterface>) rootCreatable, progressReport, cancellationToken); break; case ResourceCollectionType.StorageAccounts: await InvokeCreateIngoreErrorAsync((ICreatable <IStorageAccount>) rootCreatable, progressReport, cancellationToken); break; case ResourceCollectionType.VirtualMachines: await InvokeCreateIngoreErrorAsync((ICreatable <IVirtualMachine>) rootCreatable, progressReport, cancellationToken); break; default: await progressReport.FailedAsync(FailureRowKey, null, "Error", new InvalidOperationException($"Unknown creatable type {resourceType}"), cancellationToken); break; } } } }