你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Data - Upload Preview

上传请求允许调用方将数据内容上传到其Azure Maps帐户。
适用于: S1 定价层。

数据上传 API 允许调用方将数据内容上传到Azure Maps服务。 可以在上传格式的地理围栏GeoJSON集合等方案中使用此 API,以便在Azure Maps地理围栏服务中使用。

注意

Azure Maps 数据服务停用

Azure Maps 数据服务(v1v2)现已弃用,并将于 2024 年 9 月 16 日开始停用。 为了避免服务中断,对数据服务的所有调用都需要在 2024 年 9 月 16 日之前更新为使用 Azure Maps 数据注册表服务。 有关详细信息,请参阅如何创建数据注册表

提交上传请求

若要上传内容,你将使用请求 POST 。 请求正文将包含要上传的数据。 标头 Content-Type 将设置为数据的内容类型。

例如,若要以格式上传地理围栏 GeoJSON 集合,请将请求正文设置为地理围栏内容。 将 dataFormat 查询参数设置为 geojson,并将 Content-Type 标头设置为以下任一媒体类型:

  • application/json
  • application/vnd.geo+json
  • application/octet-stream

以下用于上传简单地理围栏的示例请求正文表示为使用中心点和半径的圆形几何图形。 以下示例位于 中 GeoJSON

{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [-122.126986, 47.639754]
        },
        "properties": {
            "geometryId": "001",
            "radius": 500
        }
    }]
}

数据上传 API 执行长时间运行的操作。

数据上传限制

请注意,目前每个Azure Maps帐户都有数据存储限制。 达到存储限制后,所有新的上传 API 调用都将返回 409 Conflict http 错误响应。 始终可以使用 数据删除 API 删除旧内容/未使用的内容,并为新上传创建空间。

POST https://{geography}.atlas.microsoft.com/mapData/upload?api-version=1.0&dataFormat={dataFormat}
POST https://{geography}.atlas.microsoft.com/mapData/upload?subscription-key={subscription-key}&api-version=1.0&dataFormat={dataFormat}

URI 参数

名称 必需 类型 说明
geography
path True

string

此参数指定 Azure Maps Creator 资源所在的位置。 有效值是 us 和 eu。

api-version
query True

string

Azure Maps API 的版本号。 当前版本为 1.0

dataFormat
query True

UploadDataFormat

正在上传的内容的数据格式。

subscription-key
query

string

从 Azure Maps 帐户提供的 Azure Maps 密钥之一。 有关如何管理身份验证的详细信息,请参阅 本文

请求头

名称 必需 类型 说明
x-ms-client-id

string

指定要与Microsoft Entra ID安全模型一起使用的帐户。 它表示Azure Maps帐户的唯一 ID,可以从Azure Maps管理平面帐户 API 检索。 若要在 Azure Maps 中使用Microsoft Entra ID安全性,请参阅以下文章以获取指导。

请求正文

名称 类型 说明
UploadContent

object

要上传的内容。

响应

名称 类型 说明
200 OK

ODataErrorResponse

数据上传失败。 上传的内容未满足所有验证检查。 响应正文包含遇到的所有错误。

201 Created

LongRunningOperationResult

已成功创建资源。

标头

Location: string

202 Accepted

仅异步请求支持。 请求已接受:已接受请求进行处理。 请使用位置标头中的 URL 重试或访问结果。

标头

Location: string

400 Bad Request

ODataErrorResponse

错误请求:一个或多个参数未正确指定或互斥。

401 Unauthorized

ODataErrorResponse

由于订阅密钥无效或Microsoft Entra ID持有者令牌无效,访问被拒绝。 请确保为活动的 Azure 订阅和 Maps 资源提供有效的密钥。 否则,请验证 WWW-Authenticate 标头中提供的Microsoft Entra ID持有者令牌的错误代码和说明。

标头

WWW-Authenticate: string

403 Forbidden

ODataErrorResponse

权限、容量或身份验证问题。

404 Not Found

ODataErrorResponse

未找到:找不到请求的资源,但将来可能再次可用。

500 Internal Server Error

ODataErrorResponse

处理该请求时出错。 请稍后再试。

安全性

AADToken

这些是 OAuth 2.0 流Microsoft Entra。 与 Azure 基于角色的访问控制配对后,它可用于控制对 Azure Maps REST API 的访问。 Azure 基于角色的访问控制用于指定对一个或多个Azure Maps资源帐户或子资源的访问权限。 可以通过内置角色或由一个或多个权限组成的自定义角色授予任何用户、组或服务主体访问权限,以Azure Maps REST API。

若要实现方案,建议查看 身份验证概念。 总之,此安全定义提供了一个解决方案,用于通过能够对特定 API 和作用域进行访问控制的对象对应用程序 () 建模。

备注

  • 此安全定义需要使用x-ms-client-id 标头来指示应用程序请求访问哪个Azure Maps资源。 这可以从 地图管理 API 获取。

Authorization URL特定于 Azure 公有云实例。 主权云具有唯一的授权 URL 和Microsoft Entra ID配置。 * Azure 基于角色的访问控制是通过 Azure 门户、PowerShell、CLI、Azure SDK 或 REST API 从 Azure 管理平面配置的。 * 使用 Azure Maps Web SDK 可以针对多个用例基于配置设置应用程序。

类型: oauth2
流向: implicit
授权 URL: https://login.microsoftonline.com/common/oauth2/authorize

作用域

名称 说明
https://atlas.microsoft.com/.default https://atlas.microsoft.com/.default

subscription-key

这是在Azure 门户或使用 PowerShell、CLI、Azure SDK 或 REST API 创建Azure Maps帐户时预配的共享密钥。

使用此密钥,任何应用程序都可以访问所有 REST API。 换句话说,此密钥可以用作颁发它们的帐户中的主密钥。

对于公开的应用程序,我们建议使用机密客户端应用程序方法来访问Azure Maps REST API,以便安全地存储密钥。

类型: apiKey
在: query

SAS Token

这是一个共享访问签名令牌,通过 Azure 管理平面通过 Azure 门户、PowerShell、CLI、Azure SDK 或 REST API 在Azure Maps资源上列出 SAS 操作创建。

使用此令牌,任何应用程序都有权使用 Azure 基于角色的访问控制进行访问,并精细控制特定令牌的过期、速率和区域 () 。 换句话说,SAS 令牌可用于允许应用程序以比共享密钥更安全的方式控制访问。

对于公开的应用程序,我们建议在 映射帐户资源 上配置允许的来源的特定列表,以限制呈现滥用,并定期续订 SAS 令牌。

类型: apiKey
在: header

示例

Upload GeoJSON data containing geometries that represent a collection of geofences

示例请求

POST https://us.atlas.microsoft.com/mapData/upload?subscription-key=[subscription-key]&api-version=1.0&dataFormat=geojson

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -122.126986,
          47.639754
        ]
      },
      "properties": {
        "geometryId": "001",
        "radius": 500
      }
    }
  ]
}

示例响应

Location: https://atlas.microsoft.com/mapData/metadata/{udid}?api-version=1.0
Access-Control-Expose-Headers: Location
{
  "operationId": "{operationId}",
  "status": "Succeeded",
  "created": "2020-01-02 1:02:03 AM +00:00",
  "resourceLocation": "https://atlas.microsoft.com/mapData/metadata/{resourceId}?api-version=1.0"
}
operation-Location: https://atlas.microsoft.com/mapData/operations/{operationId}?api-version=1.0
Access-Control-Expose-Headers: Location
{
  "error": {
    "code": "400 Bad Request",
    "message": "Upload request failed. Your data has been removed as we encountered the following problems with it: Map data is not a valid GeoJSON geometry."
  }
}
{
  "error": {
    "code": "400 BadRequest",
    "message": "Bad request: one or more parameters were incorrectly specified or are mutually exclusive."
  }
}
{
  "error": {
    "code": "401 Unauthorized",
    "message": "Access denied due to invalid subscription key. Make sure to provide a valid key for an active subscription."
  }
}
{
  "error": {
    "code": "403 Forbidden",
    "message": "Permission, capacity, or authentication issues."
  }
}
{
  "error": {
    "code": "404 NotFound",
    "message": "Not Found: the requested resource could not be found, but it may be available again in the future."
  }
}
{
  "error": {
    "code": "500 InternalServerError",
    "message": "An error occurred while processing the request. Please try again later."
  }
}

定义

名称 说明
LongRunningOperationResult

Long-Running 操作 API 的响应模型。

ODataError

Azure Maps API 中发生错误时,将返回此对象。

ODataErrorResponse

Azure Maps API 中发生错误时,将返回此响应对象。

type

请求的状态。

UploadDataFormat

正在上传的内容的数据格式。

LongRunningOperationResult

Long-Running 操作 API 的响应模型。

名称 类型 说明
created

string

创建的时间戳。

error

ODataError

Azure Maps API 中发生错误时,将返回此对象。

operationId

string

此长时间运行的操作的 ID。

resourceLocation

string

有关所创建资源的详细信息的位置 URI。 仅当请求成功完成时,才提供此选项。

status

type

请求的状态。

warning

ODataError

Azure Maps API 中发生错误时,将返回此对象。

ODataError

Azure Maps API 中发生错误时,将返回此对象。

名称 类型 说明
code

string

ODataError 代码。

details

ODataError[]

Azure Maps API 中发生错误时,将返回此对象。

message

string

如果可用,则为错误的可读说明。

target

string

如果可用,则为导致错误的目标。

ODataErrorResponse

Azure Maps API 中发生错误时,将返回此响应对象。

名称 类型 说明
error

ODataError

Azure Maps API 中发生错误时,将返回此对象。

type

请求的状态。

名称 类型 说明
Failed

string

请求有一个或多个失败。

NotStarted

string

请求尚未开始处理。

Running

string

请求已开始处理。

Succeeded

string

请求已成功完成。

UploadDataFormat

正在上传的内容的数据格式。

名称 类型 说明
geojson

string

GeoJSON 是基于 JSON 的地理空间数据交换格式。

zip

string

压缩的数据格式。