AWS SDK for .NET#

S3 access using aws-sdk-net#

To use AWS SDK for .NET (AWSSDK.core version 3.3.22.3 or later) with NGN Cloud object storage, go through the next steps:

  1. Download credentials for your cloud account as a text file .sh.

  2. Init environment variables with cloud account credentials.

  3. Create a .NET project and add packages AWSSDK.Core and AWSSDK.S3 from AWS documentation to it.

  4. Add file endpoints.json to the project and set Copy to Output Directory: Copy always to this file, or place it to buildout directory.

    endpoints.json
    {
      "endpoints": {
        "ngn/s3": {
          "endpoint": "s3.cloud.{region}.com.tr",
          "auth-region": "ngn"
        },
        "ngn/ec2": {
          "endpoint": "monitoring.cloud.{region}.com.tr",
          "auth-region": "ngn"
        },
        "ngn/monitoring": {
          "endpoint": "ec2.cloud.{region}.com.tr"
        }
      },
      "partitions": [
        {
          "defaults": {
            "protocols": [ "https" ],
            "signatureVersions": [ "v4" ]
          },
          "dnsSuffix": "cloud.ngn.com.tr",
          "partition": "ngn",
          "partitionName": "NGN Cloud",
          "regionRegex": "^ngn$",
          "regions": {
            "ngn": {
              "description": "Main NGN Cloud region"
            }
          },
          "services": {
            "ec2": {
              "defaults": {
                "hostname": "ec2.cloud.{region}.com.tr",
                "protocols": [ "http", "https" ]
              },
              "endpoints": {
                "ngn": {}
              }
            },
            "monitoring": {
              "defaults": {
                "hostname": "monitoring.cloud.{region}.com.tr",
                "protocols": [ "http", "https" ]
              },
              "endpoints": {
                "ngn": {}
              }
            },
            "s3": {
              "defaults": {
                "hostname": "s3.cloud.{region}.com.tr",
                "protocols": [ "http", "https" ],
                "signatureVersions": [ "s3", "s3v4" ]
              },
              "endpoints": {
                "ngn": {}
              }
            }
          }
        }
      ],
      "version": 3
    }
    
  5. Add aws section to App.config file:

    App.config#
    <aws region="ngn"/>
    
  6. Create api client:

    Program.cs#
    var client = new AmazonS3Client();