powershell - Set-AzureDeployment 忽略相对路径

标签 powershell azure

PS C:\Users\dimon\src\panama\Panama> Set-AzureDeployment -Config -ServiceName pms-dimon -Slot "Production" -Configuration .\ServiceConfiguration.Test.cscfg -Verbose
Set-AzureDeployment : Could not find a part of the path 'C:\Users\dimon\ServiceConfiguration.Test.cscfg'.
At line:1 char:1
+ Set-AzureDeployment -Config -ServiceName pms-dimon -Slot "Production" -Configur ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Set-AzureDeployment], DirectoryNotFoundException
    + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.SetAzureDeploymentCommand

Set-AzureDeployment 不是在当前目录中查找 ServiceConfigiration.Test.cscfg 文件,而是希望在当前用户的主目录中找到此文件,该文件坦率地说,非常令人讨厌。

是否有一些常见的 Powershell 模式可以从主目录开始运行所有 cmdlet 函数?为什么?

最佳答案

您可以显式传递完整路径:

Set-AzureDeployment -Config -ServiceName pms-dimon -Slot "Production" `
  -Configuration $(rvpa .\ServiceConfiguration.Test.cscfg) -Verbose

回答你的问题:不,PowerShell 对主目录没有做任何特殊的事情。但是,如果您执行 cd,则暴露给非 PowerShell 命令的当前目录的值 ([Environment]::CurrentDirectory) 不会更改,这通常是源的惊喜。如果 Set-AzureDeployment 将其参数传递给非 PowerShell 命令,则可以解释该行为。

要以一般方式解决此问题,您只需在发出进一步命令之前将当前目录更改为 PowerShell 的位置即可:

[Environment]::CurrentDirectory = $(pwd)

显然,这只适用于当前位置位于文件系统中的情况,而不适用于 PowerShell 支持的任何其他特殊位置。

关于powershell - Set-AzureDeployment 忽略相对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28565764/

相关文章:

java - 将 Azure 媒体服务缩略图任务预设与 Java SDK 结合使用

c# - 是否可以在 Windows Azure 上指定时区?

powershell - 与 DSC 一起安装时,巧克力包缓存在哪里

powershell - 使用powershell在文本文件中找到特定行后如何停止Get-Content -wait?按需退出管道

excel - 如何显示(或防止隐藏)从 PowerShell 创建的 Excel 工作表

c# - 使用 EF 从 Azure 移动服务检索父/子记录(包含列表的对象)

azure - 如果为资源提交两个或多个同名元数据 header ,Blob 服务会返回 200 或 400? (Azure Blob 服务)

powershell - Powershell错误: “There is not enough memory or disk to complete the operation”

powershell - 需要自签名证书 Win2012 r2 SHA256 4 年到期

.net - 在 Azure 上托管 SignalR Hub 而不使用 Web 的项目架构