Azurite Blob service is starting at http://127.0.0.1:10000 Azurite Queue service is starting at http://127.0.0.1:10001 Azurite Table service is starting at http://127.0.0.1:10002
import azure.functions as func from azure.identity import DefaultAzureCredential from azure.mgmt.compute import ComputeManagementClient import logging, os
except Exception as e: logging.error('異常錯誤: %s', str(e))
異常問題:EnvironmentCredential
1 2 3 4 5 6 7 8 9 10
DefaultAzureCredential failed to retrieve a token from the included credentials. Attempted credentials: EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured. Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot this issue. ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint. SharedTokenCacheCredential: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache. AzureCliCredential: Azure CLI not found on path AzurePowerShellCredential: PowerShell is not installed AzureDeveloperCliCredential: Azure Developer CLI could not be found. Please visit https://aka.ms/azure-dev for installation instructions and then,once installed, authenticate to your Azure account using 'azd auth login'. To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
這個問題表面上看似由於權限不足引起的,但實際上根本原因是缺乏正確的環境變數配置。 要使 Azure Function 能夠正常運作並獲得所需的權限,我們需要在 Function 的環境設置中正確配置相應的環境變數。 這些環境變數包括關鍵的憑證和授權信息,它們使得 Azure Function 能夠在執行過程中獲取必要的存取權限,從而能夠正常與 Azure 資源進行交互。 如果環境變數配置不當或缺失,Azure Function 將無法獲得所需的授權,從而導致權限不足的錯誤。 確保這些環境變數被正確設置和管理,是解決此類問題的關鍵步驟
-- 創建表 CREATETABLE Users ( Id SERIAL PRIMARY KEY, Username VARCHAR(255) NOTNULL, IsDeleted BOOLEANDEFAULTFALSE );
ALTER SEQUENCE users_id_seq RESTART WITH1000; -- 創建部分索引,只針對 IsDeleted = FALSE 的行 CREATEUNIQUE INDEX unique_active_username ON Users (Username) WHERE IsDeleted =FALSE;
+-----------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=========================================================================================| | No running processes found | +-----------------------------------------------------------------------------------------+
> nvidia-smi Mon Jul 1 09:21:24 2024 +---------------------------------------------------------------------------------------+ | NVIDIA-SMI 535.183.01 Driver Version: 535.183.01 CUDA Version: 12.2 | |-----------------------------------------+----------------------+----------------------+ | GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |=========================================+======================+======================| | 0 Tesla T4 Off | 00000001:00:00.0 Off | Off | | N/A 31C P8 9W / 70W | 140MiB / 16384MiB | 0% Default | | | | N/A | +-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=======================================================================================| | 0 N/A N/A 1095 G /usr/lib/xorg/Xorg 130MiB | | 0 N/A N/A 1356 G /usr/bin/gnome-shell 7MiB | +---------------------------------------------------------------------------------------+
我發現使用 Security Type 為 Trusted Launch 的 VM 所建立的 Snapshot; 與其建立的 Disk 與 VM 其 Security Type 也會是 Trusted Launch。 但是當我嚐試透過 SSH using Azure CLI 連線 VM, 會遇到無法連線的問題,同樣的步驟,Security Type 為 Standard 就不會有問題。 待確認原因…