Deployments - Calculate Template Hash

Calculate the hash of the given template.

POST https://management.azure.com/providers/Microsoft.Resources/calculateTemplateHash?api-version=2021-04-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

TemplateHashResult

OK - Returns the hash.

Other Status Codes

CloudError

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=2021-04-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

Name Description
CloudError

An error response for a resource management request.

ErrorAdditionalInfo

The resource management error additional info.

ErrorResponse

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

ErrorResponse

Error Response
Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.)

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info

object

The additional info.

type

string

The additional info type.

ErrorResponse

Error Response

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorResponse[]

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.