# Getting started with the Yandex Cloud SDK

[Yandex Cloud SDK](overview.md) is a set of development tools for interfacing with cloud infrastructure.

To illustrate some of the SDK features, we will walk you through creating a Yandex Compute Cloud [VM](../../compute/concepts/vm.md) step by step.

To get started with the Yandex Cloud SDK:
1. [Get your cloud ready](#before-begin).
    1. [Create a service account](#create-sa).
    1. [Prepare the Yandex Cloud CLI](#prepare-cli).
    1. [Get the source data](#get-source-data).
1. [Configure the environment](#prepare-project).
1. [Create a configuration file](#create-config).
1. [Prepare the script code](#prepare-code).
1. [Run the script to create a VM](#run-code).

If you no longer need the resources you created, [delete them](#clear-out).

See also [SDK use cases](#examples).

## Get your cloud ready {#before-begin}

Sign up for Yandex Cloud and create a [billing account](../../billing/concepts/billing-account.md):
1. Navigate to the [management console](https://console.yandex.cloud) and log in to Yandex Cloud or create a new account.
1. On the **[Yandex Cloud Billing](https://center.yandex.cloud/billing/accounts)** page, make sure you have a billing account linked and it has the `ACTIVE` or `TRIAL_ACTIVE` [status](../../billing/concepts/billing-account-statuses.md). If you do not have a billing account, [create one](../../billing/quickstart/index.md) and [link](../../billing/operations/pin-cloud.md) a cloud to it.

If you have an active billing account, you can create or select a [folder](../../resource-manager/concepts/resources-hierarchy.md#folder) for your infrastructure on the [cloud page](https://console.yandex.cloud/cloud).

[Learn more about clouds and folders here](../../resource-manager/concepts/resources-hierarchy.md).

### Required paid resources {#paid-resources}

The cost of supporting a VM created with the SDK includes:
* Fee for VM computing resources (see [Yandex Compute Cloud](../../compute/pricing.md#prices-instance-resources) pricing).
* Fee for VM disks (see [Yandex Compute Cloud](../../compute/pricing.md#prices-storage) pricing).
* Fee for using a dynamic external IP address (see [Yandex Virtual Private Cloud pricing](../../vpc/pricing.md#prices-public-ip)).

### Create a service account {#create-sa}

1. [Create](../../iam/operations/sa/create.md) a service account.
1. [Assign](../../organization/operations/add-role.md) [roles](../../iam/concepts/access-control/roles.md) to the service account based on the services you want to manage with the Yandex Cloud SDK.

    In this tutorial, you will need the [compute.admin](../../compute/security/index.md#compute-admin) role to create a VM. 
    
    If you are going to use the **SDK for .NET**, also assign the [iam.serviceAccounts.admin](../../iam/security/index.md#iam-serviceAccounts-admin) role to the service account. You will need this role to get an [authorized key](../../iam/concepts/authorization/key.md).

### Prepare the Yandex Cloud CLI {#prepare-cli}

1. [Install](../../cli/operations/install-cli.md) the Yandex Cloud CLI.
1. [Authenticate](../../cli/operations/authentication/service-account.md) in the Yandex Cloud CLI as a service account.

    With the Yandex Cloud CLI, you will get the Yandex Cloud authentication credentials:
    * For Node.js, Go, Python, and Java: [IAM token](../../iam/concepts/authorization/iam-token.md).
    * For .NET: [Authorized key](../../iam/concepts/authorization/key.md).

### Get the source data {#get-source-data}

1. [Get](../../resource-manager/operations/folder/get-id.md) the ID of the folder within which to work with services using the Yandex Cloud SDK.
1. [Select](../../compute/operations/images-with-pre-installed-software/get-list.md) a suitable image for your VM. Save the [image family](../../compute/concepts/image.md#family) ID, e.g., `ubuntu-2204-lts`.
1. [Create](../../compute/operations/vm-connect/ssh.md#creating-ssh-keys) a pair of SSH keys to [connect to your VM](../../compute/operations/vm-connect/ssh.md). 

## Prepare your working directory {#prepare-project}

{% list tabs group=instructions %}

- Node.js {#nodejs}

    1. In the terminal, check the Node.js version using this command: 

        ```bash
        node -v
        ```

        The Yandex Cloud SDK supports Node.js version 12 and higher. If Node.js is not installed or you need a newer version, select the appropriate installation option from the [Node.js website](https://nodejs.org/en/download/package-manager).
    1. Clone the [repository containing the Yandex Cloud SDK examples for Node.js](https://github.com/yandex-cloud-examples/yc-sdk-quickstart-node-js.git):

        ```bash
        git clone https://github.com/yandex-cloud-examples/yc-sdk-quickstart-node-js.git
        ```

    1. Go to your cloned repository and install the dependencies:

        ```bash
        cd yc-sdk-quickstart-node-js && npm i
        ```

- Go {#go}

    1. In the terminal, check the Go version using this command: 

        ```bash
        go version
        ```

        If Go is not installed, select the appropriate installation option from the [Go website](https://go.dev/doc/install).
    1. Clone the [repository containing the Yandex Cloud SDK examples for Go](https://github.com/yandex-cloud-examples/yc-sdk-quickstart-go.git):

        ```bash
        git clone https://github.com/yandex-cloud-examples/yc-sdk-quickstart-go.git
        ```

    1. Go to your cloned repository and install the dependencies:

        ```bash
        cd yc-sdk-quickstart-go && go tidy
        ```
    
- Python {#python}

    1. In the terminal, check the Python version using this command for Linux and macOS: 

        ```bash
        python3 --version
        ```

        or Windows:

        ```bash
        python --version
        ```
        
        If Python is not installed, select the appropriate installation option from the [Python website](https://www.python.org/downloads).
    1. Clone the [repository containing the Yandex Cloud SDK examples for Python](https://github.com/yandex-cloud-examples/yc-sdk-quickstart-python.git):

        ```bash
        git clone https://github.com/yandex-cloud-examples/yc-sdk-quickstart-python.git
        ```

    1. Go to your cloned repository and install the dependencies:

        ```bash
        cd yc-sdk-quickstart-python && pip install yandexcloud
        ```

- Java {#java}

    1. In the terminal, check the Java version using this command: 

        ```bash
        java --version
        ```

        If Java is not installed, select the appropriate installation option from the [Oracle website](https://www.oracle.com/java/technologies/downloads/).
    1. Additionally, install [Apache Maven](https://maven.apache.org/install.html) to build your project.
    1. Clone the [repository containing the Yandex Cloud SDK examples for Java](https://github.com/yandex-cloud-examples/yc-sdk-quickstart-java.git):

        ```bash
        git clone https://github.com/yandex-cloud-examples/yc-sdk-quickstart-java.git
        ```

    1. Got to your cloned repository:

        ```bash
        cd yc-sdk-quickstart-java
        ```

- .NET {#dotnet}

    1. In the terminal, check the .NET version using this command: 

        ```bash
        dotnet -version
        ```

        If .NET is not installed, select the appropriate installation option from the [Microsoft website](https://dotnet.microsoft.com/en-us/download). We recommend installing version 9.0 as it is used in this guide. If you install a different version of .NET, specify it in the `YC-test` file.
    1. Clone the [repository containing the Yandex Cloud SDK examples for .NET](https://github.com/yandex-cloud-examples/yc-sdk-quickstart-dotnet.git):

        ```bash
        git clone https://github.com/yandex-cloud-examples/yc-sdk-quickstart-dotnet.git
        ```

    1. In the cloned repository, go to the `yc-sdk-quickstart-dotnet` directory:

        ```bash
        cd yc-sdk-quickstart-dotnet
        ```

{% endlist %}

## Set up a configuration file {#create-config}

{% list tabs group=instructions %}

- Node.js {#nodejs}

    Open the `config.json` file. It already contains a basic VM configuration, but you can customize it:

    ```json
    {
        "folder_id": "<folder_ID>",
        "username": "user",
        "resources": {
            "image": {
                "family": "ubuntu-2204-lts",
                "folder_family_id": "standard-images"
            },
            "name": "computer",
            "resources_spec": {
                "memory": 2147483648,
                "cores": 2
            },
            "boot_disk_spec": {
                "auto_delete": true,
                "disk_spec": {
                    "type_id": "network-hdd",
                    "size": 10737418240
                }
            },
            "zone_id": "ru-central1-d",
            "platform_id": "standard-v3",
            "subnet_id": "<subnet_ID>"
        },
        "metadata": {
            "ssh-keys": "USERNAME:SSH_PUBLIC_KEY",
            "user-data": "#cloud-config\n    datasource:\n      Ec2:\n        strict_id: false\n    users:\n      - name: USERNAME\n        sudo: 'ALL=(ALL) NOPASSWD:ALL'\n        shell: /bin/bash\n        ssh_authorized_keys:\n          - SSH_PUBLIC_KEY"
        },
        "labels": {
            "yc-sdk": "yes"
        }
    }
    ```
    
    Where:  
    * `folder_id`: [Folder](../../resource-manager/concepts/resources-hierarchy.md#folder) ID.
    * `username`: VM user name.
    * `family`: [Image family](../../compute/concepts/image.md#family) ID.
    * `folder_family_id`: ID of the folder the images are in; for [public images](../../compute/concepts/image.md#public), `standard-images`.
    * `name`: VM name.
    * `memory`: RAM size, in bytes.
    * `cores`: Number of vCPUs.
    * `auto_delete`: Delete the disk together with the VM.
    * `type_id`: VM [disk type](../../compute/concepts/disk.md#disks-types).
    * `size`: Disk size, in bytes.
    * `zone_id`: [Availability zone](../concepts/geo-scope.md) you want to put the VM in.
    * `platform_id`: [Platform](../../compute/concepts/vm-platforms.md) ID.
    * `subnet_id`: [Subnet](../../vpc/concepts/network.md#subnet) ID.
    * `metadata`: [VM metadata](../../compute/concepts/vm-metadata.md).
    * `labels`: VM [label](../../resource-manager/concepts/labels.md).

- Go {#go}

    Open the `config.json` file. It already contains a basic VM configuration, but you can customize it:

    ```json
    {
        "folder_id": "<folder_ID>",
        "username": "user",
        "resources": {
            "image": {
                "family": "ubuntu-2204-lts",
                "folder_family_id": "standard-images"
            },
            "name": "computer",
            "resources_spec": {
                "memory": 2147483648,
                "cores": 2
            },
            "boot_disk_spec": {
                "auto_delete": true,
                "disk_spec": {
                    "type_id": "network-hdd",
                    "size": 10737418240
                }
            },
            "zone_id": "ru-central1-d",
            "platform_id": "standard-v3",
            "subnet_id": "<subnet_ID>"
        },
        "metadata": {
            "ssh-keys": "USERNAME:SSH_PUBLIC_KEY",
            "user-data": "#cloud-config\n    datasource:\n      Ec2:\n        strict_id: false\n    users:\n      - name: USERNAME\n        sudo: 'ALL=(ALL) NOPASSWD:ALL'\n        shell: /bin/bash\n        ssh_authorized_keys:\n          - SSH_PUBLIC_KEY"
        },
        "labels": {
            "yc-sdk": "yes"
        }
    }
    ```
    
    Where:  
    * `folder_id`: [Folder](../../resource-manager/concepts/resources-hierarchy.md#folder) ID.
    * `username`: VM user name.
    * `family`: [Image family](../../compute/concepts/image.md#family) ID.
    * `folder_family_id`: ID of the folder the images are in; for [public images](../../compute/concepts/image.md#public), `standard-images`.
    * `name`: VM name.
    * `memory`: RAM size, in bytes.
    * `cores`: Number of vCPUs.
    * `auto_delete`: Delete the disk together with the VM.
    * `type_id`: VM [disk type](../../compute/concepts/disk.md#disks-types).
    * `size`: Disk size, in bytes.
    * `zone_id`: [Availability zone](../concepts/geo-scope.md) you want to put the VM in.
    * `platform_id`: [Platform](../../compute/concepts/vm-platforms.md) ID.
    * `subnet_id`: [Subnet](../../vpc/concepts/network.md#subnet) ID.
    * `metadata`: [VM metadata](../../compute/concepts/vm-metadata.md).
    * `labels`: VM [label](../../resource-manager/concepts/labels.md).

- Python {#python}

    Open the `config.json` file. It already contains a basic VM configuration, but you can customize it:

    ```json
    {
        "folder_id": "<folder_ID>",
        "username": "user",
        "resources": {
            "image": {
                "family": "ubuntu-2204-lts",
                "folder_family_id": "standard-images"
            },
            "name": "computer",
            "resources_spec": {
                "memory": 2147483648,
                "cores": 2
            },
            "boot_disk_spec": {
                "auto_delete": true,
                "disk_spec": {
                    "type_id": "network-hdd",
                    "size": 10737418240
                }
            },
            "zone_id": "ru-central1-d",
            "platform_id": "standard-v3",
            "subnet_id": "<subnet_ID>"
        },
        "metadata": {
            "ssh-keys": "USERNAME:SSH_PUBLIC_KEY",
            "user-data": "#cloud-config\n    datasource:\n      Ec2:\n        strict_id: false\n    users:\n      - name: USERNAME\n        sudo: 'ALL=(ALL) NOPASSWD:ALL'\n        shell: /bin/bash\n        ssh_authorized_keys:\n          - SSH_PUBLIC_KEY"
        },
        "labels": {
            "yc-sdk": "yes"
        }
    }
    ```
    
    Where:  
    * `folder_id`: [Folder](../../resource-manager/concepts/resources-hierarchy.md#folder) ID.
    * `username`: VM user name.
    * `family`: [Image family](../../compute/concepts/image.md#family) ID.
    * `folder_family_id`: ID of the folder the images are in; for [public images](../../compute/concepts/image.md#public), `standard-images`.
    * `name`: VM name.
    * `memory`: RAM size, in bytes.
    * `cores`: Number of vCPUs.
    * `auto_delete`: Delete the disk together with the VM.
    * `type_id`: VM [disk type](../../compute/concepts/disk.md#disks-types).
    * `size`: Disk size, in bytes.
    * `zone_id`: [Availability zone](../concepts/geo-scope.md) you want to put the VM in.
    * `platform_id`: [Platform](../../compute/concepts/vm-platforms.md) ID.
    * `subnet_id`: [Subnet](../../vpc/concepts/network.md#subnet) ID.
    * `metadata`: [VM metadata](../../compute/concepts/vm-metadata.md).
    * `labels`: VM [label](../../resource-manager/concepts/labels.md).

- Java {#java}

    Open the `config.json` file in the `src/main/resources/config` directory. It already has a basic VM configuration installed, and you need to specify `folder_id` and `subnet_id`. You can also set your custom parameters for other fields:

    ```json
    {
        "folder_id": "<folder_ID>",
        "username": "user",
        "resources": {
            "image": {
                "family": "ubuntu-2204-lts",
                "folder_family_id": "standard-images"
            },
            "name": "computer",
            "resources_spec": {
                "memory": 2147483648,
                "cores": 2
            },
            "boot_disk_spec": {
                "auto_delete": true,
                "disk_spec": {
                    "type_id": "network-hdd",
                    "size": 10737418240
                }
            },
            "zone_id": "ru-central1-d",
            "platform_id": "standard-v3",
            "subnet_id": "<subnet_ID>"
        },
        "metadata": {
            "ssh-keys": "USERNAME:SSH_PUBLIC_KEY",
            "user-data": "#cloud-config\n    datasource:\n      Ec2:\n        strict_id: false\n    users:\n      - name: USERNAME\n        sudo: 'ALL=(ALL) NOPASSWD:ALL'\n        shell: /bin/bash\n        ssh_authorized_keys:\n          - SSH_PUBLIC_KEY"
        },
        "labels": {
            "yc-sdk": "yes"
        }
    }
    ```
    
    Where:  
    * `folder_id`: [Folder](../../resource-manager/concepts/resources-hierarchy.md#folder) ID.
    * `username`: VM user name.
    * `family`: [Image family](../../compute/concepts/image.md#family) ID.
    * `folder_family_id`: ID of the folder the images are in; for [public images](../../compute/concepts/image.md#public), `standard-images`.
    * `name`: VM name.
    * `memory`: RAM size, in bytes.
    * `cores`: Number of vCPUs.
    * `auto_delete`: Delete the disk together with the VM.
    * `type_id`: VM [disk type](../../compute/concepts/disk.md#disks-types).
    * `size`: Disk size, in bytes.
    * `zone_id`: [Availability zone](../concepts/geo-scope.md) you want to put the VM in.
    * `platform_id`: [Platform](../../compute/concepts/vm-platforms.md) ID.
    * `subnet_id`: [Subnet](../../vpc/concepts/network.md#subnet) ID.
    * `metadata`: [VM metadata](../../compute/concepts/vm-metadata.md).
    * `labels`: VM [label](../../resource-manager/concepts/labels.md).

- .NET {#dotnet}

    Open the `config.json` file. It already contains a basic VM configuration, but you can customize it:

    ```json
    {
        "folder_id": "<folder_ID>",
        "username": "user",
        "resources": {
            "image": {
                "family": "ubuntu-2204-lts",
                "folder_family_id": "standard-images"
            },
            "name": "computer",
            "resources_spec": {
                "memory": 2147483648,
                "cores": 2
            },
            "boot_disk_spec": {
                "auto_delete": true,
                "disk_spec": {
                    "type_id": "network-hdd",
                    "size": 10737418240
                }
            },
            "zone_id": "ru-central1-d",
            "platform_id": "standard-v3",
            "subnet_id": "<subnet_ID>"
        },
        "metadata": {
            "ssh-keys": "USERNAME:SSH_PUBLIC_KEY",
            "user-data": "#cloud-config\n    datasource:\n      Ec2:\n        strict_id: false\n    users:\n      - name: USERNAME\n        sudo: 'ALL=(ALL) NOPASSWD:ALL'\n        shell: /bin/bash\n        ssh_authorized_keys:\n          - SSH_PUBLIC_KEY"
        },
        "labels": {
            "yc-sdk": "yes"
        }
    }
    ```
    
    Where:  
    * `folder_id`: [Folder](../../resource-manager/concepts/resources-hierarchy.md#folder) ID.
    * `username`: VM user name.
    * `family`: [Image family](../../compute/concepts/image.md#family) ID.
    * `folder_family_id`: ID of the folder the images are in; for [public images](../../compute/concepts/image.md#public), `standard-images`.
    * `name`: VM name.
    * `memory`: RAM size, in bytes.
    * `cores`: Number of vCPUs.
    * `auto_delete`: Delete the disk together with the VM.
    * `type_id`: VM [disk type](../../compute/concepts/disk.md#disks-types).
    * `size`: Disk size, in bytes.
    * `zone_id`: [Availability zone](../concepts/geo-scope.md) you want to put the VM in.
    * `platform_id`: [Platform](../../compute/concepts/vm-platforms.md) ID.
    * `subnet_id`: [Subnet](../../vpc/concepts/network.md#subnet) ID.
    * `metadata`: [VM metadata](../../compute/concepts/vm-metadata.md).
    * `labels`: VM [label](../../resource-manager/concepts/labels.md).

{% endlist %}

## Run the script to create a VM {#run-code}

The project is already configured to create a VM with console commands. See comments in the code to learn more about the steps involved in creating a VM.

{% list tabs group=instructions %}

- Node.js {#nodejs}

    Run the `index.js` file using this command:

    ```bash
    IAM_TOKEN=$(yc iam create-token) \
    SSH_PUBLIC_KEY_PATH=./key.pub \
    node index.js   
    ```

    Where:
    * `IAM_TOKEN`: [IAM token](../../iam/concepts/authorization/iam-token.md) you get using the Yandex Cloud CLI. To learn more about the `yc iam create-token` command, see the [CLI reference](../../iam/operations/iam-token/create-for-sa.md).
    * `SSH_PUBLIC_KEY_PATH`: Path to the file with the public SSH key.
    
    {% note info %}
    
    Rebooting the system or terminal shell will cause all created environment variables to be lost.
    
    {% endnote %}
    
    Once you start creating a VM, you will see this text in the terminal:
    
    ```text
    Running Yandex.Cloud operation. ID: fv4qfujd49fc********
    ```
    
    Where `ID` is the VM create [operation](../../api-design-guide/concepts/about-async.md) ID.
    
    You can track the operation status in the management console as well as in the Yandex Cloud CLI and API. To learn more, see [Viewing operations with Compute Cloud resources](../../compute/operations/operation-logs.md).
    
    Once your new VM is created, you will see the following mesage:
    
    ```text
    Created with id fv4qfujd49fc********
    ```
    
    Where `id` is the VM ID.

- Go {#go}

    Run the `main.go` file using this command:

    ```bash
    IAM_TOKEN=$(yc iam create-token) \
    SSH_PUBLIC_KEY_PATH=./key.pub \
    go run main.go
    ```

    Where:
    * `IAM_TOKEN`: [IAM token](../../iam/concepts/authorization/iam-token.md) you get using the Yandex Cloud CLI. To learn more about the `yc iam create-token` command, see the [CLI reference](../../iam/operations/iam-token/create-for-sa.md).
    * `SSH_PUBLIC_KEY_PATH`: Path to the file with the public SSH key.
    
    {% note info %}
    
    Rebooting the system or terminal shell will cause all created environment variables to be lost.
    
    {% endnote %}
    
    Once you start creating a VM, you will see this text in the terminal:
    
    ```text
    Running Yandex.Cloud operation. ID: fv4qfujd49fc********
    ```
    
    Where `ID` is the VM create [operation](../../api-design-guide/concepts/about-async.md) ID.
    
    You can track the operation status in the management console as well as in the Yandex Cloud CLI and API. To learn more, see [Viewing operations with Compute Cloud resources](../../compute/operations/operation-logs.md).
    
    Once your new VM is created, you will see the following mesage:
    
    ```text
    Created with id fv4qfujd49fc********
    ```
    
    Where `id` is the VM ID.

- Python {#python}

    Run the `script.py` file using this command:

    ```bash
    IAM_TOKEN=$(yc iam create-token) \
    SSH_PUBLIC_KEY_PATH=./key.pub \
    python script.py
    ```

    Where:
    * `IAM_TOKEN`: [IAM token](../../iam/concepts/authorization/iam-token.md) you get using the Yandex Cloud CLI. To learn more about the `yc iam create-token` command, see the [CLI reference](../../iam/operations/iam-token/create-for-sa.md).
    * `SSH_PUBLIC_KEY_PATH`: Path to the file with the public SSH key.

    {% note info %}
    
    Rebooting the system or terminal shell will cause all created environment variables to be lost.
    
    {% endnote %}

    The script runs in stages:

    * **Running the script to create a VM**. If the script finds no data format errors, you will see the following message:
    
      ```text
      INFO:yandexcloud._channels:Using endpoints from configuration, IAM iam.api.cloud.yandex.net:443, compute compute.api.cloud.yandex.net:443
      INFO:yandexcloud._channels:Using endpoints from configuration, IAM iam.api.cloud.yandex.net:443, compute compute.api.cloud.yandex.net:443
      INFO:root:Creating initiated
      ```

    * **Sending data to the server for validation**. If all data is correct, you will see the following message:

      ```text
      INFO:root:Running Yandex.Cloud operation. ID: fv45g3nfq0bn********. Description: Create instance. Created at: 2024-12-19 15:52:59. Created by: ajeutahec4**********. Meta: instance_id: "fv4bi87d50**********".
      INFO:yandexcloud._channels:Using endpoints from configuration, IAM iam.api.cloud.yandex.net:443, operation operation.api.cloud.yandex.net:443
      ```
    
    * **Operation result**. After creating a VM, you will get its details:

      ```text
      INFO:root:Done Yandex.Cloud operation. ID: fv45g3nfq0bn********. Response: id: "fv42jgaq946dm8ibkjl6"
      folder_id: "b1g5hnqtug**********"
      created_at {
          seconds: 1734614895
      }
      name: "computer"
      zone_id: "ru-central1-d"
      platform_id: "standard-v3"
      resources {
          memory: 2147483648
          cores: 2
          core_fraction: 100
      }
      status: RUNNING
      metadata_options {
          gce_http_endpoint: ENABLED
          aws_v1_http_endpoint: ENABLED
          gce_http_token: ENABLED
          aws_v1_http_token: DISABLED
      }
      boot_disk {
          mode: READ_WRITE
          device_name: "fv4sd8kkspslntd0dpvn"
          auto_delete: true
          disk_id: "fv4sd8kkspslntd0dpvn"
      }
      network_interfaces {
          index: "0"
          mac_address: "d0:0d:29:c1:5a:49"
          subnet_id: "fl8b5ou7m8sihjbftcfk"
          primary_v4_address {
              address: "192.168.0.3"
              one_to_one_nat {
              address: "51.250.34.207"
              ip_version: IPV4
              }
          }
      }
      serial_port_settings {
          ssh_authorization: OS_LOGIN
      }
      gpu_settings {}
      fqdn: "fv42jgaq946dm8ibkjl6.auto.internal"
      scheduling_policy {}
      network_settings {
          type: STANDARD
      }
      placement_policy {}
      hardware_generation {
          legacy_features {
              pci_topology: PCI_TOPOLOGY_V1
          }
      }.
      WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
      E0000 00:00:1734614936.026768 4332467 init.cc:229] grpc_wait_for_shutdown_with_timeout() timed out.
      ```

- Java {#java}

    1. Build your project using this command:

        ```bash
        mvn clean package
        ```
    
    1. In the root directory of the project, run the code using this command:

        ```bash
        IAM_TOKEN=$(yc iam create-token) \
        SSH_PUBLIC_KEY_PATH=key.pub \
        java -jar target/java-sdk-examples-2.6.4-jar-with-dependencies.jar  
        ```

        Where:
        * `IAM_TOKEN`: [IAM token](../../iam/concepts/authorization/iam-token.md) you get using the Yandex Cloud CLI. To learn more about the `yc iam create-token` command, see the [CLI reference](../../iam/operations/iam-token/create-for-sa.md).
        * `SSH_PUBLIC_KEY_PATH`: Path to the file with the public SSH key.
        
        {% note info %}
        
        Rebooting the system or terminal shell will cause all created environment variables to be lost.
        
        {% endnote %}
        
        Once you start creating a VM, you will see this text in the terminal:
        
        ```text
        Running Yandex.Cloud operation. ID: fv4qfujd49fc********
        ```
        
        Where `ID` is the VM create [operation](../../api-design-guide/concepts/about-async.md) ID.
        
        You can track the operation status in the management console as well as in the Yandex Cloud CLI and API. To learn more, see [Viewing operations with Compute Cloud resources](../../compute/operations/operation-logs.md).
        
        Once your new VM is created, you will see the following mesage:
        
        ```text
        Created with id fv4qfujd49fc********
        ```
        
        Where `id` is the VM ID.

- .NET {#dotnet}

    In the root directory of the project, run the code using this command:

    ```bash
    yc iam key create \
      --output key.json \
      --service-account-name <service_account_name> && \
    AUTH_KEY=$(<key.json) && \
    rm key.json && \
    SSH_PUBLIC_KEY_PATH=~/key.pub \
    dotnet run
    ```

    This command consists of the following parts:
    * `yc iam key create`: Command to get an [authorized key](../../iam/concepts/authorization/key.md), where:
        * `--output`: Path to the file for saving the authorized key in JSON format.
        * `--service-account-name`: Name of the service account you are creating the key for.
    * `AUTH_KEY=$(<key.json>)`: Reading the authorized key file and placing the key contents in the `AUTH_KEY` variable.
    * `rm key.json`: Deleting the authorized key file. You can skip this part of the command if you plan to reuse the authorized key.
    * `SSH_PUBLIC_KEY_PATH=~/key.pub`: Providing the path to your public SSH key file to the `SSH_PUBLIC_KEY_PATH` environment variable.
    * `dotnet run`: Running the script.

    {% note info %}
    
    Rebooting the system or terminal shell will cause all created environment variables to be lost.
    
    {% endnote %}
    
    Once you start creating a VM, you will see this text in the terminal:
    
    ```text
    Running Yandex.Cloud operation. ID: fv4qfujd49fc********
    ```

    Where `ID` is the VM create [operation](../../api-design-guide/concepts/about-async.md) ID.
    
    You can track the operation status in the management console as well as in the Yandex Cloud CLI and API. To learn more, see [Viewing operations with Compute Cloud resources](../../compute/operations/operation-logs.md).

{% endlist %}

You can check the new VM in the [management console](https://console.yandex.cloud). It should have the `yc-sdk:yes` [label](../../resource-manager/concepts/labels.md).

## How to delete the resources you created {#clear-out}

To stop paying for the resources you created, [delete](../../compute/operations/vm-control/vm-delete.md) your VM from Compute Cloud.
 
# Examples of working with the SDK {#examples}

* [Node.js](https://github.com/yandex-cloud/nodejs-sdk/tree/master/examples)
* [Go](https://github.com/yandex-cloud/go-sdk/tree/master/examples)
* [Python](https://github.com/yandex-cloud/python-sdk/tree/master/examples)
* [Java](https://github.com/yandex-cloud/java-sdk/tree/master/java-sdk-examples)
* [.NET](https://github.com/yandex-cloud/dotnet-sdk/tree/master/Example)

## See also {#see-also}

[Connecting to a Linux VM over SSH](../../compute/operations/vm-connect/ssh.md)