Share via


DeploymentEnvironmentsClient.CreateOrUpdateEnvironment Method

Definition

Overloads

CreateOrUpdateEnvironment(WaitUntil, String, String, DevCenterEnvironment, CancellationToken)

Creates or updates an environment.

CreateOrUpdateEnvironment(WaitUntil, String, String, String, RequestContent, RequestContext)

[Protocol Method] Creates or updates an environment.

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.

CreateOrUpdateEnvironment(WaitUntil, String, String, DevCenterEnvironment, CancellationToken)

Source:
DeploymentEnvironmentsClient.cs

Creates or updates an environment.

public virtual Azure.Operation<Azure.Developer.DevCenter.Models.DevCenterEnvironment> CreateOrUpdateEnvironment (Azure.WaitUntil waitUntil, string projectName, string userId, Azure.Developer.DevCenter.Models.DevCenterEnvironment environment, System.Threading.CancellationToken cancellationToken = default);
abstract member CreateOrUpdateEnvironment : Azure.WaitUntil * string * string * Azure.Developer.DevCenter.Models.DevCenterEnvironment * System.Threading.CancellationToken -> Azure.Operation<Azure.Developer.DevCenter.Models.DevCenterEnvironment>
override this.CreateOrUpdateEnvironment : Azure.WaitUntil * string * string * Azure.Developer.DevCenter.Models.DevCenterEnvironment * System.Threading.CancellationToken -> Azure.Operation<Azure.Developer.DevCenter.Models.DevCenterEnvironment>
Public Overridable Function CreateOrUpdateEnvironment (waitUntil As WaitUntil, projectName As String, userId As String, environment As DevCenterEnvironment, Optional cancellationToken As CancellationToken = Nothing) As Operation(Of DevCenterEnvironment)

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

projectName
String

The DevCenter Project upon which to execute operations.

userId
String

The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.

environment
DevCenterEnvironment

Represents an environment.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

projectName, userId or environment is null.

projectName or userId is an empty string, and was expected to be non-empty.

Applies to

CreateOrUpdateEnvironment(WaitUntil, String, String, String, RequestContent, RequestContext)

Source:
DeploymentEnvironmentsClient.cs
Source:
DeploymentEnvironmentsClient.cs

[Protocol Method] Creates or updates an environment.

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
public virtual Azure.Operation<BinaryData> CreateOrUpdateEnvironment (Azure.WaitUntil waitUntil, string projectName, string userId, string environmentName, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member CreateOrUpdateEnvironment : Azure.WaitUntil * string * string * string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation<BinaryData>
override this.CreateOrUpdateEnvironment : Azure.WaitUntil * string * string * string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation<BinaryData>
Public Overridable Function CreateOrUpdateEnvironment (waitUntil As WaitUntil, projectName As String, userId As String, environmentName As String, content As RequestContent, Optional context As RequestContext = Nothing) As Operation(Of BinaryData)

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

projectName
String

The DevCenter Project upon which to execute operations.

userId
String

The AAD object id of the user. If value is 'me', the identity is taken from the authentication context.

environmentName
String

The name of the environment.

content
RequestContent

The content to send as the body of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The Operation representing an asynchronous operation on the service.

Exceptions

projectName, userId, environmentName or content is null.

projectName, userId or environmentName is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call CreateOrUpdateEnvironment and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeploymentEnvironmentsClient client = new DeploymentEnvironmentsClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    environmentType = "<environmentType>",
    catalogName = "<catalogName>",
    environmentDefinitionName = "<environmentDefinitionName>",
});
Operation<BinaryData> operation = client.CreateOrUpdateEnvironment(WaitUntil.Completed, "<projectName>", "<userId>", "<environmentName>", content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("environmentType").ToString());
Console.WriteLine(result.GetProperty("catalogName").ToString());
Console.WriteLine(result.GetProperty("environmentDefinitionName").ToString());

This sample shows how to call CreateOrUpdateEnvironment with all parameters and request content and parse the result.

Uri endpoint = new Uri("<https://my-service.azure.com>");
TokenCredential credential = new DefaultAzureCredential();
DeploymentEnvironmentsClient client = new DeploymentEnvironmentsClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    parameters = new
    {
        key = new object(),
    },
    environmentType = "<environmentType>",
    catalogName = "<catalogName>",
    environmentDefinitionName = "<environmentDefinitionName>",
});
Operation<BinaryData> operation = client.CreateOrUpdateEnvironment(WaitUntil.Completed, "<projectName>", "<userId>", "<environmentName>", content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("parameters").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("name").ToString());
Console.WriteLine(result.GetProperty("environmentType").ToString());
Console.WriteLine(result.GetProperty("user").ToString());
Console.WriteLine(result.GetProperty("provisioningState").ToString());
Console.WriteLine(result.GetProperty("resourceGroupId").ToString());
Console.WriteLine(result.GetProperty("catalogName").ToString());
Console.WriteLine(result.GetProperty("environmentDefinitionName").ToString());
Console.WriteLine(result.GetProperty("error").GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("error").GetProperty("message").ToString());
Console.WriteLine(result.GetProperty("error").GetProperty("target").ToString());
Console.WriteLine(result.GetProperty("error").GetProperty("innererror").GetProperty("code").ToString());

Applies to