json
  • powershell
  • azure
  • runbook
  • 2017-10-14 50 views 0 likes 
    0

    我需要在Azure中运行手册使用波纹管命令的文件目录:如何通过JSON对象本身,而不是通过使用新AzureRmDataFactoryLinkedService

    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

    据微软文档[ New-AzureRmDataFactoryLinkedService](https://docs.microsoft.com/de-de/powershell/module/azurerm.datafactories/new-azurermdatafactorylinkedservice?view=azurermps-4.4.0)'-File'参数需要指向json文件。没有其他的。所以不行。没有这条线会起作用。 –

    回答

    1

    根据执行运行手册,其中上,一个可能性是你的JSON数据写入到一个临时文件:

    $jsonFilePath = 'C:\Windows\Temp\StorageLinkedService_JSON_str.json' 
    $StorageLinkedService_JSON_str | 
        Out-File -FilePath $jsonFilePath 
    New-AzureRmDataFactoryLinkedService $MyDataFactoryObject -File $jsonFilePath 
    
    +0

    它的工作:D谢谢曼 –

    相关问题