0

我需要在 Azure Runbooks 中使用以下命令:

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
4

1 回答 1

1

根据运行手册的执行位置,可能会将 JSON 数据写入临时文件:

$jsonFilePath = 'C:\Windows\Temp\StorageLinkedService_JSON_str.json'
$StorageLinkedService_JSON_str | 
    Out-File -FilePath $jsonFilePath
New-AzureRmDataFactoryLinkedService $MyDataFactoryObject -File $jsonFilePath
于 2017-10-15T09:16:53.817 回答