【问题标题】:Error: Need to specify the physical directory for the virtual path 'Web/' of role错误:需要为角色的虚拟路径“Web/”指定物理目录
【发布时间】:2016-07-25 16:23:16
【问题描述】:

我正在关注此问题底部的答案:ASP.NET 5 web application as Azure Web Role?,因为我正在尝试为 asp.net 核心构建一个 azure web 角色。

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

错误CloudServices077:需要为角色的虚拟路径'Web/'指定物理目录

如果有人知道在 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

ServiceDefinition.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>

文件夹结构(如果有区别的话……)

【问题讨论】:

    标签: powershell azure asp.net-core


    【解决方案1】:

    我错过了这一行的 phsycial 目录:&lt;Site name="Web" physicalDirectory="../SoundVast"&gt;。在此之后,我运行了脚本,它为我创建了一个包。这方面的文档确实不好。

    <?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>
    

    【讨论】:

      【解决方案2】:

      我遇到了这个问题,并通过从我的云服务(它是一个 MVC)中删除 Web 角色并生成一个新角色来解决它。我做了这么多修改,结果变得一团糟,所以从头开始制作一个新的解决了这个问题

      【讨论】:

      • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
      猜你喜欢
      • 2016-07-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-29
      • 2010-11-17
      • 1970-01-01
      相关资源
      最近更新 更多