Mendapatkan informasi koneksi untuk instance

Cuplikan ini menunjukkan cara mengambil informasi koneksi, termasuk alamat IP dan nama instance, untuk instance tertentu. Gunakan informasi ini untuk menghubungkan aplikasi klien ke database Anda.

Contoh kode

C#

Untuk melakukan autentikasi ke AlloyDB, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, lihat Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

using Google.Cloud.AlloyDb.V1;

public sealed partial class GeneratedAlloyDBAdminClientSnippets
{
    /// <summary>Snippet for GetConnectionInfo</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public void GetConnectionInfo()
    {
        // Create client
        AlloyDBAdminClient alloyDBAdminClient = AlloyDBAdminClient.Create();
        // Initialize request argument(s)
        string parent = "projects/[PROJECT]/locations/[LOCATION]/clusters/[CLUSTER]/instances/[INSTANCE]";
        // Make the request
        ConnectionInfo response = alloyDBAdminClient.GetConnectionInfo(parent);
    }
}

Langkah berikutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat browser contohGoogle Cloud .