// TODO: when this is a async task, in orchestration await this will make orchestration cannot be completed, need investigation public void SaveDeploymentOperation(DeploymentOperation deploymentOperation) { TraceActivityEventSource.Log.TraceEvent( TraceEventType.Information, "DeploymentOperationsActivity", deploymentOperation.InstanceId, deploymentOperation.ExecutionId, $"{deploymentOperation.Type}:{deploymentOperation.ResourceId}:{(int)deploymentOperation.Stage}", deploymentOperation.Input, deploymentOperation.Stage.ToString()); using var db = new DbAccess(this.options.Database.ConnectionString); db.AddStatement(this._saveDeploymentOperationCommandString, deploymentOperation); db.ExecuteNonQueryAsync().Wait(); }
public async Task <DeploymentOperation> Run(DeploymentOrchestrationInput args) { if (string.IsNullOrEmpty(args.DeploymentId)) { throw new ArgumentNullException("DeploymentId"); } if (string.IsNullOrEmpty(args.ApiVersion)) { throw new ArgumentNullException("ApiVersion"); } if (string.IsNullOrEmpty(args.CorrelationId)) { throw new ArgumentNullException("CorrelationId"); } if (string.IsNullOrEmpty(args.DeploymentName)) { throw new ArgumentNullException("DeploymentName"); } if (string.IsNullOrEmpty(args.GroupId)) { throw new ArgumentNullException("GroupId"); } if (string.IsNullOrEmpty(args.GroupType)) { throw new ArgumentNullException("GroupType"); } if (string.IsNullOrEmpty(args.HierarchyId)) { throw new ArgumentNullException("HierarchyId"); } if (string.IsNullOrEmpty(args.TenantId)) { throw new ArgumentNullException("TenantId"); } if (string.IsNullOrEmpty(args.SubscriptionId) && string.IsNullOrEmpty(args.ManagementGroupId)) { throw new ArgumentException("SubscriptionId and ManagementGroupId must set one"); } if (!string.IsNullOrEmpty(args.SubscriptionId) && !string.IsNullOrEmpty(args.ManagementGroupId)) { throw new ArgumentException("SubscriptionId and ManagementGroupId only one can be set value"); } if (string.IsNullOrEmpty(args.CreateByUserId)) { throw new ArgumentNullException("CreateByUserId"); } var operation = new DeploymentOperation(args, this._Infrastructure) { RootId = args.DeploymentId, InstanceId = args.DeploymentId, ExecutionId = "PLACEHOLDER", Stage = ProvisioningStage.Pending, Input = _DataConverter.Serialize(args) }; var instance = await _OrchestrationWorkerClient.JumpStartOrchestrationAsync(new Job { InstanceId = args.DeploymentId, Orchestration = new OrchestrationSetting() { Name = DeploymentOrchestration.Name, Version = args.ApiVersion }, Input = _DataConverter.Serialize(args) }); operation.ExecutionId = instance.ExecutionId; return(operation); }