Dienstendpunkt festlegen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
In diesem Beispiel wird gezeigt, wie Sie bei Verwendung der BigQuery-Clientbibliotheken einen alternativen Endpunkt festlegen.
Codebeispiel
Nächste Schritte
Wenn Sie nach Codebeispielen für andere Google Cloud -Produkte suchen und filtern möchten, können Sie den Google Cloud -Beispielbrowser verwenden.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis page demonstrates how to configure an alternate endpoint when utilizing the BigQuery client libraries in both Go and Node.js.\u003c/p\u003e\n"],["\u003cp\u003eThe Go code sample illustrates the use of \u003ccode\u003ebigquery.NewClient\u003c/code\u003e with \u003ccode\u003eoption.WithEndpoint\u003c/code\u003e to set a custom endpoint.\u003c/p\u003e\n"],["\u003cp\u003eThe Node.js code sample shows how to create a BigQuery client with a specific API endpoint using the \u003ccode\u003eapiEndpoint\u003c/code\u003e configuration.\u003c/p\u003e\n"],["\u003cp\u003eBoth code samples are referencing the client libraries and require authentication by setting up Application Default Credentials.\u003c/p\u003e\n"]]],[],null,["# set the service endpoint\n\nThis sample demonstrates how to set an alternate endpoint when using the BigQuery client libraries.\n\nCode sample\n-----------\n\n### Go\n\n\nBefore trying this sample, follow the Go setup instructions in the\n[BigQuery quickstart using\nclient libraries](/bigquery/docs/quickstarts/quickstart-client-libraries).\n\n\nFor more information, see the\n[BigQuery Go API\nreference documentation](https://godoc.org/cloud.google.com/go/bigquery).\n\n\nTo authenticate to BigQuery, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for client libraries](/bigquery/docs/authentication#client-libs).\n\n import (\n \t\"context\"\n \t\"fmt\"\n\n \t\"cloud.google.com/go/bigquery\"\n \t\"google.golang.org/api/option\"\n )\n\n // setClientEndpoint creates a bigquery.Client pointing\n // to a specific endpoint.\n func setClientEndpoint(endpoint, projectID string) (*bigquery.Client, error) {\n \t// projectID := \"my-project-id\"\n \t// endpoint := \"https://bigquery.googleapis.com/bigquery/v2/\n \tctx := context.Background()\n \tclient, err := bigquery.NewClient(ctx, projectID, option.WithEndpoint(endpoint))\n \tif err != nil {\n \t\treturn nil, fmt.Errorf(\"bigquery.NewClient: %w\", err)\n \t}\n \tdefer client.Close()\n\n \treturn client, nil\n }\n\n### Node.js\n\n\nBefore trying this sample, follow the Node.js setup instructions in the\n[BigQuery quickstart using\nclient libraries](/bigquery/docs/quickstarts/quickstart-client-libraries).\n\n\nFor more information, see the\n[BigQuery Node.js API\nreference documentation](https://googleapis.dev/nodejs/bigquery/latest/index.html).\n\n\nTo authenticate to BigQuery, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for client libraries](/bigquery/docs/authentication#client-libs).\n\n // Import the Google Cloud client library\n const {BigQuery} = require('https://cloud.google.com/nodejs/docs/reference/bigquery/latest/overview.html');\n\n function setClientEndpoint() {\n // Create a bigquery client pointing to a specific endpoint\n\n /**\n * TODO(developer): Uncomment the following line of code and fill in your region before running the sample.\n */\n // const region = 'my-region';\n\n const bigquery = new https://cloud.google.com/nodejs/docs/reference/bigquery/latest/bigquery/bigquery.html({\n apiEndpoint: `${region}-bigquery.googleapis.com`,\n });\n\n console.log('API Endpoint:');\n console.log(bigquery.apiEndpoint);\n }\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=bigquery)."]]