连接到AzureAppsessionationClient时出现填充错误

tkclm6bt  于 2023-11-21  发布在  其他
关注(0)|答案(1)|浏览(111)

我使用下面的代码来获取keyvault值,但在运行代码时,我得到了错误raise binaslog.Error(“Connection string secret has incorrect padding”)binaslog.Error:Connection string secret has incorrect padding

from azure.appconfiguration import AzureAppConfigurationClient
from azure.identity import DefaultAzureCredential. I have updated the latest package as well.
from azure.keyvault.secrets import SecretClient

app_string_url = "Endpoint=https://xxx.azconfig.io;Id=123;Secret=123" # not used
secret_name = 'ACS_ENDPOINT'

# Create an instance of AzureAppConfigurationClient
credential=DefaultAzureCredential()

app_config_client = AzureAppConfigurationClient.from_connection_string(connection_string=app_string_url)

    
config_setting = app_config_client.get_configuration_setting(secret_name)

# error at last line

字符串

xxb16uws

xxb16uws1#

你可以使用下面的代码来做同样的事情,并遵循Microsoft-Document

from azure.identity import ClientSecretCredential
from azure.appconfiguration import AzureAppConfigurationClient

tenant_id1 = "83331f4e"
client_id1 = "5461f88"
client_secret1 = "jXI8Q"
app_config_endpoint = "https://apptest.azconfig.io"

secret_key1 = "secret name"
rithcreds = ClientSecretCredential(tenant_id1, client_id1, client_secret1)
app_configuration_client = AzureAppConfigurationClient(app_config_endpoint, rithcreds)
secret_value = app_configuration_client.get_configuration_setting(secret_key1).value
print(secret_value)

字符串
或者,您可以按照此SO-Thread获取秘密。

相关问题