Azure 云服务配置架构(.cscfg 文件)Azure Cloud Services Config Schema (.cscfg File)

服务配置文件指定要为服务中每个角色部署的角色实例数、任何配置设置的值,以及与角色关联的任何证书的缩略图。The service configuration file specifies the number of role instances to deploy for each role in the service, the values of any configuration settings, and the thumbprints for any certificates associated with a role. 如果服务属于虚拟网络,必须在服务配置文件以及虚拟网络配置文件中提供网络的配置信息。If the service is part of a Virtual Network, configuration information for the network must be provided in the service configuration file, as well as in the virtual networking configuration file. 服务配置文件的默认扩展名为 .csdef。The default extension for the service configuration file is .cscfg.

通过云服务(经典)定义架构描述服务模型。The service model is described by the Cloud Service (classic) Definition Schema.

默认情况下,Azure 诊断配置架构文件将安装到 C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\<version>\schemas 目录。By default, the Azure Diagnostics configuration schema file is installed to the C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\<version>\schemas directory. <version> 替换为 Azure SDK 的已安装版本。Replace <version> with the installed version of the Azure SDK.

有关在服务中配置角色的详细信息,请参阅什么是云服务模型For more information about configuring roles in a service, see What is the Cloud Service model.

基本服务配置架构Basic Service Configuration Schema

服务配置文件的基本格式如下所示。The basic format of the service configuration file is as follows.

<ServiceConfiguration serviceName="<service-name>" osFamily="<osfamily-number>" osVersion="<os-version>" schemaVersion="<schema-version>">

  <Role …>
    …
  </Role>

  <NetworkConfiguration>
    …
  </NetworkConfiguration>

</ServiceConfiguration>

架构定义Schema definitions

以下主题介绍 ServiceConfiguration 元素的架构:The following topics describe the schema for the ServiceConfiguration element:

服务配置命名空间Service Configuration Namespace

服务配置文件的 XML 命名空间是:http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfigurationThe XML namespace for the service configuration file is: http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration.

ServiceConfiguration 元素ServiceConfiguration Element

ServiceConfiguration 元素是服务配置文件的顶层元素。The ServiceConfiguration element is the top-level element of the service configuration file.

下表介绍了 ServiceConfiguration 元素的属性。The following table describes the attributes of the ServiceConfiguration element. 所有属性值均为字符串类型。All attributes values are string types.

属性Attribute 说明Description
serviceNameserviceName 必需。Required. 云服务的名称。The name of the cloud service. 此处提供的名称需要匹配服务定义文件中指定的名称。The name given here must match the name specified in the service definition file.
osFamilyosFamily 可选。Optional. 指定要在云服务的角色实例上运行的来宾 OS。Specifies the Guest OS that will run on role instances in the cloud service. 有关支持的来宾 OS 版本的信息,请参阅 Azure 来宾 OS 版本和 SDK 兼容性对照表For information about supported Guest OS releases, see Azure Guest OS Releases and SDK Compatibility Matrix.

如果不包含 osFamily 值,并且未将 osVersion 属性设置为特定的来宾 OS 版本,将使用默认值 1。If you do not include an osFamily value and you have not set the osVersion attribute to a specific Guest OS version, a default value of 1 is used.
osVersionosVersion 可选。Optional. 指定要在云服务的角色实例上运行的来宾 OS 版本。Specifies the version of the Guest OS that will run on role instances in the cloud service. 有关来宾 OS 版本的详细信息,请参阅 Azure 来宾 OS 版本和 SDK 兼容性对照表For more information about Guest OS versions, see Azure Guest OS Releases and SDK Compatibility Matrix.

可以指定应自动将来宾 OS 升级到最新版本。You can specify that the Guest OS should be automatically upgraded to the latest version. 若要执行此操作,将 osVersion 属性的值设为 *To do this, set the value of the osVersion attribute to *. 如果设置为 *,将使用指定 OS 系列的最新来宾 OS 版本部署角色实例,并且在发布新版来宾 OS 后自动进行升级。When set to *, the role instances are deployed using the latest version of the Guest OS for the specified OS family and will be automatically upgraded when new versions of the Guest OS are released.

若要手动指定特定版本,请使用来自 Azure 来宾 OS 版本和 SDK 兼容性对照表的“将来、当前和过渡来宾 OS 版本”部分的表格中的 Configuration StringTo specify a specific version manually, use the Configuration String from the table in the Future, Current and Transitional Guest OS Versions section of Azure Guest OS Releases and SDK Compatibility Matrix.

osVersion 属性的默认值为 *The default value for the osVersion attribute is *.
schemaVersionschemaVersion 可选。Optional. 指定服务配置架构的版本。Specifies the version of the Service Configuration schema. 如果并行安装多个版本的 SDK,架构版本允许 Visual Studio 选择正确的 SDK 工具用于架构验证。The schema version allows Visual Studio to select the correct SDK tools to use for schema validation if more than one version of the SDK is installed side-by-side. 有关架构和版本兼容性的信息,请参阅 Azure 来宾 OS 版本和 SDK 兼容性对照表For more information about schema and version compatibility, see Azure Guest OS Releases and SDK Compatibility Matrix

服务配置文件必须包含一个 ServiceConfiguration 元素。The service configuration file must contain one ServiceConfiguration element. ServiceConfiguration 元素可包含任意数量的 Role 元素或 0 到 1 个 NetworkConfiguration 元素。The ServiceConfiguration element may include any number of Role elements and zero or 1 NetworkConfiguration elements.