Amazon.ElasticBeanstalk.AmazonElasticBeanstalkClient.CreateEnvironmentAsync C# (CSharp) Method

CreateEnvironmentAsync() public method

Initiates the asynchronous execution of the CreateEnvironment operation.
public CreateEnvironmentAsync ( CreateEnvironmentRequest request, System cancellationToken = default(CancellationToken) ) : Task
request Amazon.ElasticBeanstalk.Model.CreateEnvironmentRequest Container for the necessary parameters to execute the CreateEnvironment operation.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
return Task
        public Task<CreateEnvironmentResponse> CreateEnvironmentAsync(CreateEnvironmentRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new CreateEnvironmentRequestMarshaller();
            var unmarshaller = CreateEnvironmentResponseUnmarshaller.Instance;

            return InvokeAsync<CreateEnvironmentRequest,CreateEnvironmentResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }

Usage Example

        private async Task CreateIisNextEnvironmentAsync(string environmentIdentifier, string version, List<ConfigurationOptionSetting> optionSettings)
        {
            loggerProvider.GetLogger()
                .Debug("New environment - creating \"Next\" {identifier} {version}...", environmentIdentifier, version);
            using (var ebClient = new AmazonElasticBeanstalkClient(creds, configurationProvider.RegionEndpoint))
            {
                var optionSettingsApp = GetAppSpecificCreateConfigurationOptionSettings();
                loggerProvider.GetLogger().Debug("Parsed configuration option settings: {@optionSettings}", optionSettingsApp);
                optionSettings = InjectAppSpecificOptionSettings(optionSettings, optionSettingsApp);
                loggerProvider.GetLogger()
                    .Debug("Create next environment: total option settings count - {optionSettingsCount}",
                        optionSettings.Count);

                var currentEnvironmentName = $"{configurationProvider.BeanstalkEnvironmentName}-{environmentIdentifier}";
                var createEnvironmentRequest =
                    new CreateEnvironmentRequest(configurationProvider.LongApplicationName,
                        currentEnvironmentName)
                    {
                        Tier = new EnvironmentTier { Name = "WebServer", Type = "Standard" },
                        SolutionStackName = "64bit Windows Server Core 2012 R2 running IIS 8.5",
                        CNAMEPrefix = nextCNamePrefix,
                        VersionLabel = version,
                        OptionSettings = optionSettings
                    };
                var createEnvironmentResponse = await ebClient.CreateEnvironmentAsync(createEnvironmentRequest);
                await EnsureCreateEnvironmentCompleteAsync(createEnvironmentResponse.EnvironmentId);
                loggerProvider.GetLogger()
                    .Debug("Created \"Next\" environment: {@createEnvironmentResponse}", createEnvironmentResponse);
                // TODO: capture createEnvironmentResponse.Cname as TestUri - SRO
            }
        }
All Usage Examples Of Amazon.ElasticBeanstalk.AmazonElasticBeanstalkClient::CreateEnvironmentAsync
AmazonElasticBeanstalkClient