移动应用和移动服务中的客户端与服务器版本控制Client and server versioning in Mobile Apps and Mobile Services

Azure 移动服务的最新版本是 Azure 应用服务的 移动应用 功能。The latest version of Azure Mobile Services is the Mobile Apps feature of Azure App Service.

移动应用客户端和服务器 SDK 最初基于移动服务中的 SDK,但它们彼此 兼容。The Mobile Apps client and server SDKs are originally based on those in Mobile Services, but they are not compatible with each other. 也就是说,必须将移动应用 客户端 SDK 与移动应用 服务器 SDK 配合使用,移动服务 也是如此。That is, you must use a Mobile Apps client SDK with a Mobile Apps server SDK and similarly for Mobile Services. 可以通过客户端和服务器 SDK 使用的特殊标头值 ZUMO-API-VERSION来强制实施此合约。This contract is enforced through a special header value used by the client and server SDKs, ZUMO-API-VERSION.

注意:每当本文档提到 移动服务 后端时,该后端不一定要托管在移动服务中。Note: whenever this document refers to a Mobile Services backend, it does not necessarily need to be hosted on Mobile Services. 现在,可以将移动服务迁移到应用服务上运行,而无需更改任何代码,但服务还是使用移动服务 SDK 版本。It is now possible to migrate a mobile service to run on App Service without any code changes, but the service would still be using Mobile Services SDK versions.

标头规范Header specification

可以在 HTTP 标头或查询字符串中指定键 ZUMO-API-VERSIONThe key ZUMO-API-VERSION may be specified in either the HTTP header or the query string. 值为版本字符串,格式为 x.y.zThe value is a version string in the form x.y.z.

例如:For example:

GET https://service.chinacloudsites.cn/tables/TodoItemGET https://service.chinacloudsites.cn/tables/TodoItem

标头:ZUMO-API-VERSION:2.0.0HEADERS: ZUMO-API-VERSION: 2.0.0

POST https://service.chinacloudsites.cn/tables/TodoItem?ZUMO-API-VERSION=2.0.0POST https://service.chinacloudsites.cn/tables/TodoItem?ZUMO-API-VERSION=2.0.0

选择不进行版本检查Opting out of version checking

可以将应用设置“MS_SkipVersionCheck” 的值设置为“true” ,选择不进行版本检查。You can opt out of version checking by setting a value of true for the app setting MS_SkipVersionCheck. 在 web.config 中或在 Azure 门户的“应用程序设置”部分中可以指定此设置。Specify this either in your web.config or in the Application Settings section of the Azure portal.

Note

移动服务和移动应用之间有许多行为发生了变化,尤其是在脱机同步、身份验证和推送通知方面。There are a number of behavior changes between Mobile Services and Mobile Apps, particularly in the areas of offline sync, authentication, and push notifications. 应在完成测试之后才选择不要进行版本检查,以确保这些行为的更改不会影响应用功能。You should only opt out of version checking after complete testing to ensure that these behavioral changes do not break your app's functionality.

Azure 移动应用客户端和服务器Azure Mobile Apps client and server

移动 应用 客户端 SDKMobile Apps client SDKs

版本检查从 Azure 移动应用以下版本的客户端 SDK 开始引入:Version checking was introduced starting with the following versions of the client SDK for Azure Mobile Apps:

客户端平台Client platform 版本Version 版本标头值Version header value
托管客户端(Windows、Xamarin)Managed client (Windows, Xamarin) 2.0.02.0.0 2.0.02.0.0
iOSiOS 3.0.03.0.0 2.0.02.0.0
AndroidAndroid 3.0.03.0.0 3.0.03.0.0

移动 应用 服务器 SDKMobile Apps server SDKs

以下服务器 SDK 版本包含版本检查:Version checking is included in following server SDK versions:

服务器平台Server platform SDK 中 IsInRole 中的声明SDK 接受的版本标头Accepted version header
.NET.NET Microsoft.Azure.Mobile.ServerMicrosoft.Azure.Mobile.Server 2.0.02.0.0
Node.jsNode.js azure-mobile-apps)azure-mobile-apps) 2.0.02.0.0

移动应用后端的行为Behavior of Mobile Apps backends

ZUMO-API-VERSIONZUMO-API-VERSION MS_SkipVersionCheck 的值Value of MS_SkipVersionCheck 响应Response
x.y.z 或 Nullx.y.z or Null TrueTrue 200 - 正常200 - OK
NullNull False/未指定False/Not Specified 400 - 错误的请求400 - Bad Request
1.x.y1.x.y False/未指定False/Not Specified 400 - 错误的请求400 - Bad Request
2.0.0-2.x.y2.0.0-2.x.y False/未指定False/Not Specified 200 - 正常200 - OK
3.0.0-3.x.y3.0.0-3.x.y False/未指定False/Not Specified 400 - 错误的请求400 - Bad Request