Пример #1
0
        public async Task <DeploymentExtended> GetDeploymentStatus(DeploymentStatusRequest deployStatus, string token)
        {
            try
            {
                var credential = new TokenCredentials(token);
                var resourceManagementClient = new ResourceManagementClient(credential)
                {
                    SubscriptionId = deployStatus.SubscriptionId
                };

                // Get the deployment status, return output properties when Succeeded
                var deploymentOutput = await resourceManagementClient.Deployments.GetAsync(
                    deployStatus.ApplicationName, deployStatus.ApplicationName);

                //TODO: uncomment this to add this just to check status of each resource deployment
                //var deploymentDetails = await resourceManagementClient.DeploymentOperations.ListAsync(deployStatus.ApplicationName,
                //    deployStatus.ApplicationName);

                return(deploymentOutput);
            }
            catch (Exception e)
            {
                Log.Error("Status of Deployment error {@error}", e.Message);
                throw e;
            }
        }
        public async Task <DeploymentExtended> GetDeploymentStatus(DeploymentStatusRequest deployStatus)
        {
            try
            {
                var resourceManagementClient = await clientFactory.GetResourceMangementClientAsync(deployStatus.SubscriptionId);

                // Get the deployment status, return output properties when Succeeded
                var deploymentOutput = await resourceManagementClient.Deployments.GetAsync(
                    deployStatus.ApplicationName, deployStatus.ApplicationName);

                //TODO: uncomment this to add this just to check status of each resource deployment
                //var deploymentDetails = await resourceManagementClient.DeploymentOperations.ListAsync(deployStatus.ApplicationName,
                //    deployStatus.ApplicationName);

                return(deploymentOutput);
            }
            catch (Exception e)
            {
                logger.LogError(e, "Status of Deployment error {error}", e.Message);
                throw;
            }
        }
        public async Task <IActionResult> GetDeployStatus([FromBody] DeploymentStatusModel deployStatus)
        {
            try
            {
                logger.LogInformation("Status of deployed application: {application}", deployStatus.ApplicationName);
                DeploymentStatusRequest deployReq = new DeploymentStatusRequest()
                {
                    ApplicationName = deployStatus.ApplicationName,
                    SubscriptionId  = deployStatus.SubscriptionId,
                };

                var deployment = await _resourceManagerRepo.GetDeploymentStatus(deployReq);

                if (deployment.Properties.ProvisioningState.Equals("Succeeded") &&
                    deployment.Properties.Outputs != null)
                {
                    var deploymentOutput = JsonConvert.DeserializeObject <DeploymentTemplateOutputModel>(deployment.Properties.Outputs.ToString());
                    deploymentOutput.properties = new Properties()
                    {
                        provisioningState = "Succeeded"
                    };
                    logger.LogInformation("Status of deployed completed - application url is: {url}", deploymentOutput.DataPacketDesignerURL.Value);
                    return(Ok(deploymentOutput));
                }
                else
                {
                    logger.LogInformation("Deployment status is Running: {url}");
                    return(Ok(deployment));
                }
            }
            catch (Exception e)
            {
                logger.LogError(e, "Deploy application - Exception {message}", e.Message);
                throw;
            }
        }