我正在撰寫一個登錄 Azure 的腳本,但我不想明確使用我的密碼。因此,我打開了系統分配的托管標識:

現在在一個 shell 腳本中我這樣做:
az login --identity --username xxx
'xxx' 是螢屏截圖中的物件(主體)ID
當我執行命令時,我得到了這個(用“xxx”替換了 ip 和 ID):
Failed to connect to MSI. Please make sure MSI is configured correctly and check the network connection.
Error detail: HTTPConnectionPool(host='XXX.XXX.XXX.XXX', port=XX): Max retries exceeded with url: /metadata/identity/oauth2/token?resource=https://management.core.windows.net/&api-version=2018-02-01&client_id=xxx (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x04B7DB08>:
Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'))
編輯:很好,當我在 Azure 門戶上的 Cloud-Shell 中運行此命令時。
為什么我無法登錄?我錯過了什么嗎?
uj5u.com熱心網友回復:
系統分配的托管標識不能用于登錄。它明確地與您為其創建的服務相關聯,并且不能重復使用。
系統分配的. 某些 Azure 服務允許您直接在服務實體上啟用托管標識。啟用系統分配的托管標識時,會在 Azure AD 中創建一個標識。身份與該服務實體的生命周期相關聯。洗掉資源后,Azure 會自動為你洗掉標識。按照設計,只有該 Azure 資源可以使用此標識從 Azure AD 請求令牌。
這句話最重要的部分是最后一句話:
按照設計,只有該 Azure 資源可以使用此標識從 Azure AD 請求令牌。
詳細資訊:什么是 Azure 資源的托管標識?.
還:
不能共享。
它只能與單個 Azure 資源相關聯。
編輯:
根據您的問題和下面的評論,您可能正在尋找Service Principal。托管標識(系統分配或用戶分配)用于 Azure 資源。
托管標識為應用程式在連接到支持 Azure AD 身份驗證的資源時使用的標識提供。
Azure 服務主體是為與應用程式、托管服務和自動化工具一起使用以訪問 Azure 資源而創建的標識。
有關服務主體的詳細資訊,請參閱使用 Azure CLI 創建 Azure 服務主體。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/454466.html
