powershell - 错误: Need to specify the physical directory for the virtual path 'Web/' of role

标签 powershell azure asp.net-core

我在这里关注这个问题底部的答案:ASP.NET 5 web application as Azure Web Role?因为我正在尝试为 ASP.NET Core 构建一个 Azure Web 角色。

当我运行 powershell 脚本时,出现错误:

Error CloudServices077: Need to specify the physical directory for the virtual path 'Web/' of role

如果有人知道在 ASP.NET Core 中使用 Azure Web 角色的另一种方法,那么我也完全支持。

我正在使用 CSPack 来尝试配置它。

Powershell 脚本:

# path to cspack
$cspackPath = Join-Path $env:ProgramFiles 'Microsoft SDKs\Azure\.NET SDK\v2.8\bin\cspack.exe'

$PackagePath = 'I:\Users\MyUserName\Documents\visual studio 2015\Projects\SoundVast\SoundVast.Azure\SoundVast.cspkg'
$serviceDefinitionFile = 'I:\Users\MyUserName\Documents\visual studio 2015\Projects\SoundVast\SoundVast.Azure\ServiceDefinition.csdef'
$webRoleName = 'WebRole1'
$webRolePath = 'I:\Users\MyUserName\Documents\visual studio 2015\Projects\SoundVast\SoundVast.Azure'

# define the cspack parameters
$cspackParameter = @(
        $serviceDefinitionFile,
        "/role:$webRoleName;$webRolePath;",
        "/sites:$webRoleName;SoundVast;$webRolePath",
        "/out:$PackagePath"
    )

# execute cspack
& $cspackPath @cspackParameter

服务定义.csdef

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="SoundVast.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
  <WebRole name="WebRole1" vmsize="Small">
    <Sites>
      <Site name="Web">
        <Bindings>
          <Binding name="Endpoint1" endpointName="Endpoint1" />
        </Bindings>
      </Site>
    </Sites>
    <ConfigurationSettings>
      <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
    </ConfigurationSettings>
    <Endpoints>
      <InputEndpoint name="Endpoint1" protocol="http" port="80" />
    </Endpoints>
  </WebRole>
</ServiceDefinition>

ServiceConfiguration.Cloud 和 ServiceConfiguration.Local

<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="SoundVast.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2015-04.2.6">
  <Role name="WebRole1">
    <Instances count="1" />
    <ConfigurationSettings>
      <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
    </ConfigurationSettings>
  </Role>
</ServiceConfiguration>

文件夹结构(如果有区别的话......) enter image description here

最佳答案

我在这一行缺少物理目录:<Site name="Web" physicalDirectory="../SoundVast"> 。之后我运行了脚本并为我创建了一个包。这方面的文档确实不好。

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="SoundVast.Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
  <WebRole name="WebRole1" vmsize="Small">
    <Sites>
      <Site name="Web" physicalDirectory="../SoundVast">
        <Bindings>
          <Binding name="Endpoint1" endpointName="Endpoint1" />
        </Bindings>
      </Site>
    </Sites>
    <ConfigurationSettings>
      <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
    </ConfigurationSettings>
    <Endpoints>
      <InputEndpoint name="Endpoint1" protocol="http" port="80" />
    </Endpoints>
  </WebRole>
</ServiceDefinition>

关于powershell - 错误: Need to specify the physical directory for the virtual path 'Web/' of role,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38572919/

相关文章:

azure - 如何跨订阅移动应用程序服务证书与 Web 应用程序及其证书

json - 将 JSON 数据发布到 Dotnet Core webapi

regex - Powershell 简单正则表达式捕获组未捕获

azure - 可选登录 + 使用 azure ad b2c 进行 SSO

azure - Blazor Web assembly Azure AD 身份验证托管在 Azure 存储帐户中

asp.net-core - Jetbrains 骑士 : [MSB4057] The target "build" does not exist in the project

asp.net-core - ASP.NET 5 中的 Request.IsAuthenticated 函数

Powershell 多行文本框输出

c# - 在 C# 中使用 "New-Object"cmdlet

Powershell使用NTLM身份验证从服务器获取文件