错误的publishsettings用于Import-AzurePublishSettingsFile命令的xml文件结构

时间:2014-05-28 15:41:33

标签: azure azure-powershell

我使用命令Get-AzurePublishSettingsFile获得了一个新的publishsettings文件

当我运行以下命令时:

Import-AzurePublishSettingsFile -SubscriptionDataFile "path to publishsettings"

我收到了这个错误:

    Import-AzurePublishSettingsFile : Error in line 1 position 14. Expecting element 'ProfileData' from namespace 'http://schemas.datacontract.org/2004/07/Microsoft.WindowsAzure.Comman
ds.Utilities.Common'.. Encountered 'Element'  with name 'PublishData', namespace ''. 
At line:1 char:1
+ Import-AzurePublishSettingsFile -SubscriptionDataFile "path to publishsettings ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Import-AzurePublishSettingsFile], SerializationException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.ImportAzurePublishSettingsCommand

看起来PowerShell cmdlet希望看到一个具有不同结构的文件,但我不知道在哪里可以得到一个。

我在这里做错了什么,或者是Azure Powershell的问题?

Azure模块版本为0.8.2

3 个答案:

答案 0 :(得分:1)

我对您的具体问题没有答案。但我可能有更好的选择,你可以尝试解决原始问题。

请参阅ArgumentNullException - Get-AzureService

该帖子描述了以下两个选项:

您可以使用常规管理门户登录凭据,而不是使用发布设置文件进行管理API身份验证。对于使用Azure powershell cmdlet,这通常是更好的选择。

如果这对您不起作用,请参阅上面的链接,了解如何清除缓存的订阅配置文件,看看是否修复了您所看到的Import-AzurePublishSettingsFile问题。

答案 1 :(得分:0)

我遇到了同样的问题。事实证明我使用了不正确的参数开关来指定设置文件。

仔细检查您使用的是-PublishSettingsFile参数,而不是-SubscriptionDataFile,如示例所示。

有关每个参数的说明,请参阅下面的powershell帮助摘录。

Parameters
-PublishSettingsFile <String>
   Specifies the full path and filename for the .publishsettings file for the Windows Azure account.  

    Required?                    true
    Position?                    1
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

-SubscriptionDataFile <String>
    Specifies the path to a file where the subscription data is stored. This parameter is optional. If it is not provided, the subscription data is imported into a default file in the user's profile.  

    Required?                    false
    Position?                    named
    Default value                
    Accept pipeline input?       false
    Accept wildcard characters?  false

答案 2 :(得分:0)

经过多次尝试,我才能完成这项工作。

您需要以管理员身份启动PowerShell ,并清楚地将路径布局为指定下载文件的文件名。

一旦我这样做了,效果很好。