# A/B Deployment Manually

A/B deployment is an update process whereby you deploy new versions of your game servers alongside your already existing game servers.

## Initial situation sketch

We have a [Fleet](/game-hosting/elements/deploymentenvironment/fleet.md) with 1 ApplicationBuild in its [GameDeploymentTemplate](/game-hosting/elements/deploymentenvironment/index/gamedeploymenttemplate.md).

This chapter assumes you already have created a new [ApplicationBuild](/game-hosting/elements/application/applicationbuild.md) for your updated software.

## Actions to perform

* create a new GameDeploymentTemplate with the new ApplicationBuild ID.
* create the new Fleet (based on the old one).
* start sending the first updated clients to the game servers running the new build in the new Fleet (e.g. a group of testers).
* if there is something wrong, downgrade those clients and send everyone back to the old build in the old Fleet. You can remove the new Fleet if you want to destroy all the game servers running the new build.
* if all went well, update all your clients and send those to the game servers running the new build.
* eventually all clients are migrated. The old Fleet can be removed.

## API example

### Step 1: get Fleet details

We need to get the Fleet object so that we can create a new one, based on this old one.

If you do not know your Fleet ID yet, you can look it up by using [`GET /fleet`](https://www.i3d.net/docs/api/v3/game-publisher#/Fleet/getFleets).

#### HTTP request

[`GET /fleet/988194285688223011`](/api/api_one.md#v3-fleet)

#### Response body

```
[
    {
        "id": "988194285688223011",
        "name": "Example Fleet",
        "deploymentEnvironmentId": "1528510395058174656",
        "deploymentProfileId": "2641748478114564847",
        "gameDeploymentTemplateId": "6629032387499739571",
        "utilityDeploymentTemplateId": "",
        "operationalStatus": 2
    }
]
```

### Step 2: create new GameDeploymentTemplate

Before we create the new Fleet, first create a new GameDeploymentTemplate with your new ApplicationBuild ID, which can be used in the new Fleet.

If you do not know your new ApplicationBuild ID yet, you can look it up by using [`GET /applicationBuild`](https://www.i3d.net/docs/api/v3/game-publisher#/ApplicationBuild/getApplicationBuilds).

#### HTTP request

[`POST /deploymentTemplate/game`](/api/api_one.md#v3-deploymenttemplate-game)

#### Request body

```
{
  "name": "Example Game Deployment Template (new)",
  "gameDeploymentTemplateBuild": [
    {
      "applicationBuildId": "817092209556457642"
    }
  ]
}
```

#### Response body

```
[
    {
        "id": "3700287048120517011",
        "fleetIds": [],
        "name": "Example Game Deployment Template (new)",
        "inUse": 0,
        "createdAt": 1567591403,
        "gameDeploymentTemplateBuild": [
            {
                "applicationBuildId": "817092209556457642"
            }
        ]
    }
]
```

### Step 3: create new Fleet

Now we can create the new Fleet based on the old Fleet, with the new GameDeploymentTemplate.

#### HTTP request

[`POST /fleet`](/api/api_one.md#v3-fleet)

#### Request body

```
{
    "name": "Example Fleet (new)",
    "deploymentEnvironmentId": "1528510395058174656",
    "deploymentProfileId": "2641748478114564847",
    "gameDeploymentTemplateId": "3700287048120517011",
    "utilityDeploymentTemplateId": ""
}
```

#### Response body

```
[
    {
        "id": "2501509179291972037",
        "name": "Example Fleet (new)",
        "deploymentEnvironmentId": "1528510395058174656",
        "deploymentProfileId": "2641748478114564847",
        "gameDeploymentTemplateId": "3700287048120517011",
        "utilityDeploymentTemplateId": "",
        "operationalStatus": 0
    }
]
```

### Step 4: activate the new Fleet

Set the new Fleet's [operationalStatus](/game-hosting/elements/deploymentenvironment/fleet.md#operational-status) property to 2 (Automatic scaling enabled) to have the platform start deploying new game servers for it.

#### HTTP request

[`PUT /fleet/2501509179291972037/operationalStatus`](/api/api_one.md#v3-fleet-fleetid-operationalstatus)

#### Request body

```
{
  "operationalStatus": 2
}
```

#### Response body

```
[
    {
        "id": "2501509179291972037",
        "name": "Example Fleet (new)",
        "deploymentEnvironmentId": "1528510395058174656",
        "deploymentProfileId": "2641748478114564847",
        "gameDeploymentTemplateId": "3700287048120517011",
        "utilityDeploymentTemplateId": "",
        "operationalStatus": 2
    }
]
```

New game servers will be deployed now, for this new Fleet and you can start sending your first clients to them.

If you spot errors with the new game servers, you could revert the creation of the new Fleet and GameDeploymentTemplate. Or you can leave them to use for later with a new build containing any fixes.

### Step 5: remove old Fleet

When everything is going well with the new game servers and once all clients have migrated to the new version, remove the old fleet.

{% hint style="info" %}
This action still needs the `markedForDeletion` property / functionality implemented!
{% endhint %}

#### HTTP request

[`DELETE /fleet/988194285688223011`](/api/api_one.md#v3-fleet)

#### Response body

```
[
    {
        "id": "988194285688223011",
        "name": "Example Fleet",
        "deploymentEnvironmentId": "1528510395058174656",
        "deploymentProfileId": "2641748478114564847",
        "gameDeploymentTemplateId": "6629032387499739571",
        "utilityDeploymentTemplateId": "",
        "operationalStatus": 2,
        "markedForDeletion": 1 <<< not implemented yet
    }
]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.i3d.net/game-hosting/processes/index/ab-deployment-manually.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
