提供意見
為地端部署或其他雲端服務供應商設定 ADC
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如果您在 Google Cloud以外的位置執行應用程式,則必須提供 Google Cloud 可辨識的憑證,才能使用 Google Cloud 服務。
Workload Identity 聯盟
如要使用外部 IdP 的憑證進行驗證,建議使用 Google Cloud 工作負載身分聯盟 ;您需要建立憑證設定檔,並設定 GOOGLE_APPLICATION_CREDENTIALS
環境變數來指向該檔案。相較於建立服務帳戶金鑰,這種做法更安全。
如需設定 ADC 適用的 Workload Identity Federation,請參閱「Workload Identity Federation with other clouds 」(與其他雲端服務搭配使用的 Workload Identity Federation)。
服務帳戶金鑰
如果無法設定 Workload Identity Federation,則必須建立服務帳戶、授予應用程式所需的 IAM 角色,並為服務帳戶建立金鑰。
如要建立服務帳戶金鑰並提供給 ADC 使用,請按照下列步驟操作:
按照「建立服務帳戶金鑰 」一文中的說明,建立具有應用程式所需角色的服務帳戶,以及該服務帳戶的金鑰。
Set the environment variable GOOGLE_APPLICATION_CREDENTIALS
to the path of the JSON file that contains your credentials.
This variable applies only to your current shell session, so if you open
a new session, set the variable again.
Example: Linux or macOS
export GOOGLE_APPLICATION_CREDENTIALS = "KEY_PATH
"
Replace KEY_PATH
with the path of the JSON file that contains your credentials.
For example:
export GOOGLE_APPLICATION_CREDENTIALS = "/home/user/Downloads/service-account-file.json"
Example: Windows
For PowerShell:
$env :GOOGLE_APPLICATION_CREDENTIALS= "KEY_PATH
"
Replace KEY_PATH
with the path of the JSON file that contains your credentials.
For example:
$env :GOOGLE_APPLICATION_CREDENTIALS= "C:\Users\username\Downloads\service-account-file.json"
For command prompt:
set GOOGLE_APPLICATION_CREDENTIALS = KEY_PATH
Replace KEY_PATH
with the path of the JSON file that contains your credentials.
注意: 設定 GOOGLE_APPLICATION_CREDENTIALS
環境變數後,ADC 會先檢查這個位置,只有在必要時才會檢查其他位置。
後續步驟
提供意見
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權 ,程式碼範例則為阿帕契 2.0 授權 。詳情請參閱《Google Developers 網站政策 》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-11 (世界標準時間)。
想進一步說明嗎?
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-11 (世界標準時間)。"],[],[],null,[]]