我如何使用 Azure 进行身份验证,以便 运行 数据工厂管道测试 python 行为?
How do I authenticate with Azure in order to run a data factory pipeline test with python behave?
我在 Azure 数据工厂上有一个管道,我想为使用 python 行为编写一个测试。现在我只想 运行 在本地进行测试。以下命令现在不会运行,因为我还没有以任何方式进行身份验证。
get_client_from_cli_profile(DataFactoryManagementClient)
错误消息说我需要 运行 'az login' 来设置帐户。
knack.util.CLIError: Please run 'az login' to setup account.
有人可以举例说明我是如何做到这一点的吗?
特征
Feature: Run pipeline
Scenario: Get pipeline
Given we get the pipeline
步骤
@given('we get the pipeline')
def get_pipeline(context):
pipeline_name = "xxx"
resource_group = "yyy"
data_factory = "zzz"
parameters={}
pipeline = get_datafactory_pipeline(pipeline_name, resource_group, data_factory, parameters)
获取管道的代码
from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.datafactory import DataFactoryManagementClient
def get_datafactory_pipeline(pipeline_name, resource_group, data_factory, parameters):
return get_client_from_cli_profile(DataFactoryManagementClient().pipelines.create_run(
resource_group_name = resource_group,
factory_name = data_factory,
pipeline_name = pipeline_name,
parameters = parameters)
双向:
1.install Azure CLI,然后 az login
访问 Azure。(下载 link:https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
2.no 需要安装 Azure CLI,但像这样更改代码:
def get_datafactory_pipeline(subscription_id,credentials,pipeline_name, resource_group, data_factory, parameters):
return DataFactoryManagementClient(credentials,subscription_id).pipelines.create_run(
resource_group_name=resource_group,
factory_name=data_factory,
pipeline_name=pipeline_name,
parameters=parameters)
你的步骤是这样的:
@given('we get the pipeline')
def get_pipeline(context):
subscription_id = '<Specify your Azure Subscription ID>'
credentials = ServicePrincipalCredentials(client_id='<Active Directory application/client ID>', secret='<client secret>', tenant='<Active Directory tenant ID>')
pipeline_name = "xxx"
resource_group = "yyy"
data_factory = "zzz"
parameters={}
pipeline = get_datafactory_pipeline(subscription_id,credentials,pipeline_name, resource_group, data_factory, parameters)
我在 Azure 数据工厂上有一个管道,我想为使用 python 行为编写一个测试。现在我只想 运行 在本地进行测试。以下命令现在不会运行,因为我还没有以任何方式进行身份验证。
get_client_from_cli_profile(DataFactoryManagementClient)
错误消息说我需要 运行 'az login' 来设置帐户。
knack.util.CLIError: Please run 'az login' to setup account.
有人可以举例说明我是如何做到这一点的吗?
特征
Feature: Run pipeline
Scenario: Get pipeline
Given we get the pipeline
步骤
@given('we get the pipeline')
def get_pipeline(context):
pipeline_name = "xxx"
resource_group = "yyy"
data_factory = "zzz"
parameters={}
pipeline = get_datafactory_pipeline(pipeline_name, resource_group, data_factory, parameters)
获取管道的代码
from azure.common.client_factory import get_client_from_cli_profile
from azure.mgmt.datafactory import DataFactoryManagementClient
def get_datafactory_pipeline(pipeline_name, resource_group, data_factory, parameters):
return get_client_from_cli_profile(DataFactoryManagementClient().pipelines.create_run(
resource_group_name = resource_group,
factory_name = data_factory,
pipeline_name = pipeline_name,
parameters = parameters)
双向:
1.install Azure CLI,然后 az login
访问 Azure。(下载 link:https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)
2.no 需要安装 Azure CLI,但像这样更改代码:
def get_datafactory_pipeline(subscription_id,credentials,pipeline_name, resource_group, data_factory, parameters):
return DataFactoryManagementClient(credentials,subscription_id).pipelines.create_run(
resource_group_name=resource_group,
factory_name=data_factory,
pipeline_name=pipeline_name,
parameters=parameters)
你的步骤是这样的:
@given('we get the pipeline')
def get_pipeline(context):
subscription_id = '<Specify your Azure Subscription ID>'
credentials = ServicePrincipalCredentials(client_id='<Active Directory application/client ID>', secret='<client secret>', tenant='<Active Directory tenant ID>')
pipeline_name = "xxx"
resource_group = "yyy"
data_factory = "zzz"
parameters={}
pipeline = get_datafactory_pipeline(subscription_id,credentials,pipeline_name, resource_group, data_factory, parameters)