Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未通过Powershell为type=AzureSqlMITable创建数据集_Azure_Powershell_Azure Sql Database_Azure Data Factory 2 - Fatal编程技术网

未通过Powershell为type=AzureSqlMITable创建数据集

未通过Powershell为type=AzureSqlMITable创建数据集,azure,powershell,azure-sql-database,azure-data-factory-2,Azure,Powershell,Azure Sql Database,Azure Data Factory 2,问题:尝试通过powershell为AzureSQLMITable创建ADF组件(如dataset)时ADF出错 分析: 错误可在BuildServer(通过DevOps运行)上复制,也可通过Windows PowerShell本地复制 在Azure Cloudshell&Powershell core中,使用相同的命令集无法再现错误 数据集的ADF错误: 无法加载资源#datasetname。请确保JSON中没有错误,并且引用的资源存在。状态:UnknownError,可能原因:为命名的:da

问题:尝试通过powershell为AzureSQLMITable创建ADF组件(如dataset)时ADF出错

分析:

错误可在BuildServer(通过DevOps运行)上复制,也可通过Windows PowerShell本地复制

在Azure Cloudshell&Powershell core中,使用相同的命令集无法再现错误

数据集的ADF错误:

无法加载资源#datasetname。请确保JSON中没有错误,并且引用的资源存在。状态:UnknownError,可能原因:为命名的:dataset$#datasetname获取失败。找不到适配器。类型:数据集

如果在ADF中手动粘贴文件(jsonfile),它将正常工作,不会出现错误

预期解决方案:如何使其与WindowsPowershell一起工作

Json文件:

{
    "name": "#datasetname",
    "properties": {
        "linkedServiceName": {
            "referenceName": "<connection name>",
            "type": "LinkedServiceReference"
        },
        "annotations": [],
        "type": "AzureSqlMITable",
        "schema": [],
         "typeProperties": {

             "tableName": {
                "value": "<StoredProcedure_Name_Name>",
                "type": "Expression"
            }
        }  
    },
    "type": "Microsoft.DataFactory/factories/datasets"
}
{
“名称”:“#数据集名称”,
“财产”:{
“linkedServiceName”:{
“referenceName”:“,
“类型”:“LinkedServiceReference”
},
“注释”:[],
“类型”:“AzureSqlMITable”,
“架构”:[],
“类型属性”:{
“表名”:{
“价值”:“,
“类型”:“表达式”
}
}  
},
“类型”:“Microsoft.DataFactory/Factorys/datasets”
}
Powershell命令:

Connect-AzureRmAccount

$BaseFolder=<FilePath>

$file = Get-ChildItem $BaseFolder -Recurse -Include *.json -Filter #somefilter -ErrorAction Stop

Set-AzureRmDataFactoryV2Dataset -DataFactoryName <datafactoryname> -Name ($file.BaseName) -ResourceGroupName <resourcegroupname> -DefinitionFile $file.FullName -Force -ErrorAction Stop 
Connect AzureRmAccount
$BaseFolder=
$file=Get ChildItem$BaseFolder-Recurse-Include*.json-Filter#somefilter-ErrorAction Stop
Set-AzureRmDataFactoryV2Dataset-DataFactoryName-Name($file.BaseName)-ResourceGroupName-DefinitionFile$file.FullName-Force-ErrorAction-Stop

使用powershell核心命令(通过CICD中的Azure powershell任务而不是Windows one中的powershell脚本)通过Az命令解决


这里的要点是,从今往后,人们应该使用Powershell core(Az),因为它将具有新功能,而windows Powershell(AzureRm)将只使用使用Powershell core命令(通过CICD中的Azure Powershell任务而不是windows one中的Powershell脚本)通过Az命令解决错误


这里的要点是,从今往后,人们应该使用Powershell core(Az),因为它将具有新功能,而windows Powershell(AzureRm)将只具有错误修复

Get ChildItem返回一个数组(在您的例子中是).json文件。最好使用
-Filter'*.json'
并通过results@Theo好啊但这不是问题,问题是数据集没有正确创建,因为
$file.BaseName
也会导致数组而不是单个字符串,我猜是通过Az命令使用powershell核心命令解析的(通过CICD中的Azure powershell任务而不是Windows one中的powershell脚本)@akshayslodha恭喜你解决了这个问题。我帮你把它作为答案发布,你可以考虑接受(标记)它(点击答案旁边的复选标记将其从灰色变为填充),这对其他社区成员是有益的。你也可以自己发布更多细节,我会删除答案。非常感谢。
getchilditem
返回一个.json文件数组。最好使用
-Filter'*.json'
并通过results@Theo好啊但这不是问题,问题是数据集没有正确创建,因为
$file.BaseName
也会导致数组而不是单个字符串,我猜是通过Az命令使用powershell核心命令解析的(通过CICD中的Azure powershell任务而不是Windows one中的powershell脚本)@akshayslodha恭喜你解决了这个问题。我帮你把它作为答案发布,你可以考虑接受(标记)它(点击答案旁边的复选标记将其从灰色变为填充),这对其他社区成员是有益的。你也可以自己发布更多细节,我会删除答案。非常感谢。