我正在尝试使用 Microsoft 此处提供的示例通过 python 创建 azure 数据工厂管道:
https://docs.microsoft.com/en-us/azure/data-factory/quickstart-create-data-factory-python
def main():
# Azure subscription ID
subscription_id = '<Specify your Azure Subscription ID>'
# This program creates this resource group. If it's an existing resource group, comment out the code that creates the resource group
rg_name = 'ADFTutorialResourceGroup'
# The data factory name. It must be globally unique.
df_name = '<Specify a name for the data factory. It must be globally unique>'
# Specify your Active Directory client ID, client secret, and tenant ID
credentials = ServicePrincipalCredentials(client_id='<Active Directory application/client ID>', secret='<client secret>', tenant='<Active Directory tenant ID>')
resource_client = ResourceManagementClient(credentials, subscription_id)
adf_client = DataFactoryManagementClient(credentials, subscription_id)
rg_params = {'location':'eastus'}
df_params = {'location':'eastus'}
但是,我无法传递如上所示的凭据,因为 azure 登录是作为管道中较早的一个单独步骤执行的,这给我留下了一个经过身份验证的 azure 会话(不能将其他凭据传递到此脚本中)。
在我运行 python 代码来创建管道之前,我通过 Jenkins 部署管道执行“az login”,这为我提供了一个经过身份验证的 azurerm 会话。我应该能够在 python 脚本中重新使用这个会话来获取数据工厂客户端,而无需再次进行身份验证。
但是,我不确定如何修改代码的客户端创建部分,因为似乎没有任何示例使用已经建立的 azurerm 会话:
adf_client = DataFactoryManagementClient(credentials, subscription_id)
rg_params = {'location':'eastus'}
df_params = {'location':'eastus'}
#Create a data factory
df_resource = Factory(location='eastus')
df = adf_client.factories.create_or_update(rg_name, df_name, df_resource)
print_item(df)
while df.provisioning_state != 'Succeeded':
df = adf_client.factories.get(rg_name, df_name)
time.sleep(1)
因此,在此与获取 df 对象之间可能需要一些额外的步骤?
元芳怎么了
相关分类