python - 无法在数据工厂上创建变量事件

标签 python azure azure-data-factory

我正在尝试使用 python 创建数据工厂资源,但在调用几个类时遇到错误

示例 - 在这里我尝试创建“设置变量事件”,但出现错误

引用:https://learn.microsoft.com/en-us/python/api/azure-mgmt-datafactory/azure.mgmt.datafactory.models.setvariableactivity?view=azure-python

错误消息

NameError: name 'SetVariableActivity' is not defined

代码

from azure.mgmt.datafactory.models import *

variable_name = 'vGetDate'
var_activity = SetVariableActivity(name = 'Get Date',variable_name= variable_name, value = '@utcnow()' )

我也收到 DatasetFolder 类的 NameError 错误。我不确定出了什么问题,我以为我已经导入了所有必需的库并且我正在 3.7 v 上使用

非常感谢您的任何意见。

最佳答案

我在我这边测试了代码,它工作正常,请与我尝试相同版本的库。

azure-common==1.1.23
azure-mgmt-datafactory==0.9.0

我的示例使用设置变量事件创建一个管道:

from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.datafactory import DataFactoryManagementClient
from azure.mgmt.datafactory.models import *

subscription_id = '<subscription-id>'
credentials = ServicePrincipalCredentials(client_id='<client-id>', secret='<client-secret>', tenant='<tenant-id>')
adf_client = DataFactoryManagementClient(credentials, subscription_id)

variable_name = 'vGetDate'
var_activity = SetVariableActivity(name = 'Get Date',variable_name= variable_name, value = '@utcnow()' )

rg_name = '<resource-group-name>'
df_name = 'joyfactory'
p_name = 'Pipeline123'
params_for_pipeline = {}
p_obj = PipelineResource(
    activities=[var_activity], parameters=params_for_pipeline)
p = adf_client.pipelines.create_or_update(rg_name, df_name, p_name, p_obj)
print(p)

enter image description here

登录门户:

enter image description here

关于python - 无法在数据工厂上创建变量事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60289113/

相关文章:

python - 使用 Pandas 比较具有不同列数的大型 CSV 文件

Azure AD - 将应用程序主体添加到组

Azure数据工厂: Source data set has a stored procedure with user-defined Table Type

azure - 自动发布数据工厂生成ARM模板

python - 用 pandas str.replace 替换多个子字符串值

python - 有没有办法在 Entry() 中存在 int 之前使 OptionMenu() 不可用?

Azure SQL 数据库高级版不可用

azure-data-factory - 使用参数的 Azure 数据工厂数据流表达式生成器

python - 使用 mod_wsgi 在 Apache 上的 Django 中找不到 CSS 文件路径

function - 您可以使用Azure函数来触发Azure逻辑应用程序吗?