我需要在Azure Runbook中使用bellow命令:
New-AzureRmDataFactoryLinkedService $MyDataFactoryObject -File "PATH/TO/JSON/STRING/FILE"
我想知道是否可以传递JSON对象而不是传递文件路径? 我的意思是这样的:
$StorageLinkedService_JSON_str = '{
"name": "StorageName",
"properties": {
"type": "AzureStorage",
"description": "",
"typeProperties": {
"connectionString": "connectionString"
}
}
}'
$StorageLinkedService_Obj = ConvertFrom-Json -InputObject $StorageLinkedService_JSON_str
# I need to know is it possible to use one of these lines?
# New-AzureRmDataFactoryLinkedService $MyDataFactoryObject -File $StorageLinkedService_JSON_str
# OR This:
# New-AzureRmDataFactoryLinkedService $MyDataFactoryObject -File $StorageLinkedService_Obj
答案 0 :(得分:1)
根据Runbook的执行位置,可能会将JSON数据写入临时文件:
$jsonFilePath = 'C:\Windows\Temp\StorageLinkedService_JSON_str.json'
$StorageLinkedService_JSON_str |
Out-File -FilePath $jsonFilePath
New-AzureRmDataFactoryLinkedService $MyDataFactoryObject -File $jsonFilePath