Deployments - Calculate Template Hash

Calculate the hash of the given template.

POST https://management.azure.com/providers/Microsoft.Resources/calculateTemplateHash?api-version=2019-10-01

URI Parameters

Name In Required Type Description
api-version
query True
  • string

The API version to use for this operation.

Request Body

Name Type Description
template
  • object

The template provided to calculate hash.

Responses

Name Type Description
200 OK

OK - Returns the hash.

Other Status Codes

Error response describing why the operation failed.

Security

azure_auth

Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

Calculate template hash

Sample Request

POST https://management.azure.com/providers/Microsoft.Resources/calculateTemplateHash?api-version=2019-10-01
{
  "$schema": "http://schemas.management.azure.com/deploymentTemplate?api-version=2014-04-01-preview",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "string": {
      "type": "string"
    }
  },
  "variables": {
    "string": "string",
    "int": 42,
    "bool": true,
    "array": [
      1,
      2,
      3,
      4
    ],
    "object": {
      "object": {
        "vmSize": "Large",
        "location": "West US"
      }
    }
  },
  "resources": [],
  "outputs": {
    "string": {
      "type": "string",
      "value": "myvalue"
    }
  }
}

Sample Response

{
  "minifiedTemplate": "{\"$SCHEMA\":\"HTTP://SCHEMAS.MANAGEMENT.AZURE.COM/DEPLOYMENTTEMPLATE?API-VERSION=2014-04-01-PREVIEW\",\"CONTENTVERSION\":\"1.0.0.0\",\"PARAMETERS\":{\"STRING\":{\"TYPE\":\"STRING\"}},\"VARIABLES\":{\"STRING\":\"STRING\",\"INT\":42,\"BOOL\":TRUE,\"ARRAY\":[1,2,3,4],\"OBJECT\":{\"OBJECT\":{\"VMSIZE\":\"LARGE\",\"LOCATION\":\"WEST US\"}}},\"RESOURCES\":[],\"OUTPUTS\":{\"STRING\":{\"TYPE\":\"STRING\",\"VALUE\":\"MYVALUE\"}}}",
  "templateHash": "695440707931307747"
}

Definitions

CloudError

An error response for a resource management request.

ErrorAdditionalInfo

The resource management error additional info.

ErrorResponse

The resource management error response.

TemplateHashResult

Result of the request to calculate template hash. It contains a string of minified template and its hash.

CloudError

An error response for a resource management request.

Name Type Description
error

The resource management error response.

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info
  • object

The additional info.

type
  • string

The additional info type.

ErrorResponse

The resource management error response.

Name Type Description
additionalInfo

The error additional info.

code
  • string

The error code.

details

The error details.

message
  • string

The error message.

target
  • string

The error target.

TemplateHashResult

Result of the request to calculate template hash. It contains a string of minified template and its hash.

Name Type Description
minifiedTemplate
  • string

The minified template string.

templateHash
  • string

The template hash.