azure - 使用命令行工具cspack时出错

标签 azure

执行 cspack 命令时出现以下错误 “错误 CloudServices051:XML 规范无效:命名空间“http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition”中的元素“WebRole”内容不完整。所需的可能元素列表:命名空间“http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition”中的“站点”。”

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="CloudService1"      xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">
<WebRole name="WebRole1" enableNativeCodeExecution="false">
<InputEndpoints>
 <InputEndpoint name="HttpIn" protocol="http" port="80"/>
</InputEndpoints>
    <ConfigurationSettings/>
</WebRole>
</ServiceDefinition>

最佳答案

根据您的示例,我猜测您正在使用 Sririam Krishnan 所著的Windows Azure 编程一书。

该书于 2010 年 5 月出版。要么该书提供了一个损坏的示例,要么此后 Azure 框架中引入了一些重大更改。

下面是第 51 页的 ServiceDefinition.csdef 文件,经过修改以与 Azure SDK v2.8 配合使用:

<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="CloudService1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" > 
  <WebRole name="WebRole1" enableNativeCodeExecution="false">
    <InputEndpoints>
      <InputEndpoint name="HttpIn" protocol="http" port="80" />
    </InputEndpoints>
    <ConfigurationSettings />
    <!-- This sites node was not included in the example -->
    <Sites>
        <Site name="TokenSite" physicalDirectory="htmlwebsite">
            <Bindings>
                <Binding name="BindingOne" endpointName="HttpIn" />
            </Bindings>     
        </Site>
    </Sites>
  </WebRole>
</ServiceDefinition>

新增内容是Sites 节点,其中包含一个站点。 physicalDirectory 属性必须指向包含 html 文件的文件夹。在添加 Sites 节点之前,cspack 实用程序失败。

有趣的是,如果您阅读 Azure Online Documentation 中的 Sites 元素,(最后更新于 2015 年 4 月 15 日),它明确表示:

If you do not specify a Sites element, your web role is hosted as legacy web role and you can only have one website hosted in your web role. ... This element is optional and a role can have only one sites block. (my italics)

关于azure - 使用命令行工具cspack时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36427184/

相关文章:

azure - 未找到版本 "GeneralPurpose"的默认服务级别目标

php - 从 Azure Active Directory 验证 JWT

java - 无法在 Azure RHEL 节点中使用 yum 访问第三方存储库

c# - Azure key 保管库 : access denied

c# - CreateDocumentCollectionIfNotExistsAsync 并不总是有效

azure - 如何通过 REST API 更新 Azure 应用服务中的容器设置?

sql - Azure sql 数据同步代理 2 无法安装

asp.net - Azure 配置设置比 Web.Config 更安全?

azure - 502 - Web 服务器在充当网关或代理服务器时收到无效响应

azure - 在 Azure DevOps 中将个人帐户连接到组织帐户