예제 #1
0
        public async Task <DeploymentExtendedInner> NewSubscriptionDeployment(string template, string parameters, string deploymentName)
        {
            var azure = GetAzureClient();

            DeploymentInner deploymentParam = new DeploymentInner()
            {
                Location   = "westus",
                Properties = new DeploymentProperties()
                {
                    Mode       = DeploymentMode.Incremental,
                    Template   = JsonConvert.DeserializeObject(template),
                    Parameters = JsonConvert.DeserializeObject(parameters),
                }
            };

            var deployment = azure.Deployments.Inner.BeginCreateOrUpdateAtSubscriptionScopeAsync(deploymentName, deploymentParam).Result;

            //var test = azure.Deployments.GetById(deployment.Id);

            var test2 = await azure.Deployments.Inner.GetAtSubscriptionScopeWithHttpMessagesAsync(deployment.Name);

            var azureFluentSubscriptionDeployment = azure.Deployments.Inner.GetAtSubscriptionScopeAsync(deployment.Name).Result;
            var k = azure.Deployments.Inner.GetAtSubscriptionScopeAsync(deployment.Name);

            return(azureFluentSubscriptionDeployment);
        }
        public override IUpdate Update()
        {
            object template = createUpdateParamter.Properties == null ? null : createUpdateParamter.Properties.Template;

            createUpdateParamter = new DeploymentInner();

            createUpdateParamter.Location = Inner.Location;
            createUpdateParamter.Tags     = Inner.Tags;
            if (Inner.Properties != null)
            {
                createUpdateParamter.Properties = new DeploymentProperties();
                createUpdateParamter.Properties.DebugSetting   = Inner.Properties.DebugSetting;
                createUpdateParamter.Properties.Mode           = Inner.Properties.Mode ?? DeploymentMode.Incremental;
                createUpdateParamter.Properties.Parameters     = Inner.Properties.Parameters;
                createUpdateParamter.Properties.ParametersLink = Inner.Properties.ParametersLink;
                createUpdateParamter.Properties.Template       = template;
                createUpdateParamter.Properties.TemplateLink   = Inner.Properties.TemplateLink;
                if (Inner.Properties.OnErrorDeployment != null)
                {
                    createUpdateParamter.Properties.OnErrorDeployment = new OnErrorDeployment();
                    createUpdateParamter.Properties.OnErrorDeployment.DeploymentName = Inner.Properties.OnErrorDeployment.DeploymentName;
                    createUpdateParamter.Properties.OnErrorDeployment.Type           = Inner.Properties.OnErrorDeployment.Type;
                }
            }
            return(base.Update());
        }
예제 #3
0
        public async Task <DeploymentExtendedInner> NewSubscriptionDeployment()
        {
            var azure    = GetAzureClient();
            var template = System.IO.File.ReadAllText(subscribeTemplatePath);

            DeploymentInner deploymentParam = new DeploymentInner()
            {
                Location   = "westus",
                Properties = new DeploymentProperties()
                {
                    Mode       = DeploymentMode.Incremental,
                    Template   = Newtonsoft.Json.JsonConvert.DeserializeObject(template),
                    Parameters = Newtonsoft.Json.JsonConvert.DeserializeObject("{}")
                }
            };

            var deployment = azure.Deployments.Inner.BeginCreateOrUpdateAtSubscriptionScopeAsync("testetag", deploymentParam).Result;

            //var test = azure.Deployments.GetById(deployment.Id);

            var test2 = await azure.Deployments.Inner.GetAtSubscriptionScopeWithHttpMessagesAsync(deployment.Name);

            var azureFluentSubscriptionDeployment = azure.Deployments.Inner.GetAtSubscriptionScopeAsync(deployment.Name).Result;
            var k = azure.Deployments.Inner.GetAtSubscriptionScopeAsync(deployment.Name);

            return(azureFluentSubscriptionDeployment);
        }
        /// <summary>
        /// Create a deployment in resource group.
        /// </summary>
        /// <param name="resourceGroup"></param>
        /// <param name="deploymentName"></param>
        /// <param name="template"></param>
        /// <param name="parameters"></param>
        /// <param name="deploymentMode"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <DeploymentExtendedInner> CreateResourceGroupDeploymentAsync(
            IResourceGroup resourceGroup,
            string deploymentName,
            object template,
            object parameters,
            DeploymentMode deploymentMode,
            CancellationToken cancellationToken = default
            )
        {
            if (resourceGroup is null)
            {
                throw new ArgumentNullException(nameof(resourceGroup));
            }
            if (string.IsNullOrWhiteSpace(deploymentName))
            {
                throw new ArgumentNullException(nameof(deploymentName));
            }
            if (template is null)
            {
                throw new ArgumentNullException(nameof(template));
            }
            if (parameters is null)
            {
                throw new ArgumentNullException(nameof(parameters));
            }

            var deploymentDefinition = new DeploymentInner {
                Properties = new DeploymentProperties {
                    Template   = template,
                    Parameters = parameters,
                    Mode       = deploymentMode,
                }
            };

            deploymentDefinition.Validate();

            var deployment = await _resourceManagementClient
                             .Deployments
                             .CreateOrUpdateAsync(
                resourceGroup.Name,
                deploymentName,
                deploymentDefinition,
                cancellationToken
                );

            return(deployment);
        }
        public override IDeployment CreateResource()
        {
            DeploymentInner inner = new DeploymentInner
            {
                Properties = new DeploymentProperties
                {
                    Mode           = Mode.Value,
                    Template       = Template,
                    TemplateLink   = TemplateLink,
                    Parameters     = Parameters,
                    ParametersLink = ParametersLink
                }
            };

            SetInner(Extensions.Synchronize(() => Manager.Inner.Deployments.CreateOrUpdateAsync(ResourceGroupName, Name, inner)));;
            return(this);
        }
        public async override Task <IDeployment> CreateResourceAsync(CancellationToken cancellationToken)
        {
            DeploymentInner inner = new DeploymentInner
            {
                Properties = new DeploymentProperties
                {
                    Mode           = Mode.Value,
                    Template       = Template,
                    TemplateLink   = TemplateLink,
                    Parameters     = Parameters,
                    ParametersLink = ParametersLink
                }
            };
            await Manager.Inner.Deployments.CreateOrUpdateAsync(ResourceGroupName, Name, inner, cancellationToken);

            return(this);
        }
예제 #7
0
        public IDeployment BeginCreate()
        {
            DeploymentInner inner = new DeploymentInner()
            {
                Properties = new DeploymentProperties
                {
                    Mode           = Mode.Value,
                    Template       = Template,
                    TemplateLink   = TemplateLink,
                    Parameters     = Parameters,
                    ParametersLink = ParametersLink
                }
            };

            Extensions.Synchronize(() => Manager.Inner.Deployments.BeginCreateOrUpdateAsync(resourceGroupName, Name, inner));
            return(this);
        }
        public async Task <IDeployment> BeginCreateAsync(CancellationToken cancellationToken = default(CancellationToken))
        {
            if (creatableResourceGroup != null)
            {
                await creatableResourceGroup.CreateAsync(cancellationToken);
            }
            DeploymentInner inner = new DeploymentInner()
            {
                Properties = new DeploymentProperties
                {
                    Mode           = Mode.Value,
                    Template       = Template,
                    TemplateLink   = TemplateLink,
                    Parameters     = Parameters,
                    ParametersLink = ParametersLink
                }
            };

            SetInner(await Manager.Inner.Deployments.BeginCreateOrUpdateAsync(resourceGroupName, Name, inner, cancellationToken));
            return(this);
        }
 /// <summary>
 /// Create a named template deployment using a template.
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// The name of the resource group. The name is case insensitive.
 /// </param>
 /// <param name='deploymentName'>
 /// The name of the deployment.
 /// </param>
 /// <param name='parameters'>
 /// Additional parameters supplied to the operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <DeploymentExtendedInner> CreateOrUpdateAsync(this IDeploymentsOperations operations, string resourceGroupName, string deploymentName, DeploymentInner parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, deploymentName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }