Skip to content

Commit 70eb8a1

Browse files
committed
add examples
1 parent 2b651f6 commit 70eb8a1

File tree

4 files changed

+61
-7
lines changed

4 files changed

+61
-7
lines changed

articles/azure-resource-manager/templates/deployment-script-template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ The life cycle of these resources is controlled by the following properties in t
308308

309309
Deployment script execution is an idempotent operation. If none of the deploymentScripts resource properties (including the inline script) is changed, the script will not be executed when you redeploy the template. The deployment script service compares the resource names in the template with the existing resources in the same resource group. There are two options if you want to execute the same deployment script multiple times:
310310

311-
- Change the name of your deploymentScripts resource. For example, use the [utcNow](./template-functions-string.md#utcnow) template function as the resource name or as a part of the resource name. Changing the resource name creates a new deploymentScripts resource. It is good for keeping a history of script execution.
311+
- Change the name of your deploymentScripts resource. For example, use the [utcNow](./template-functions-date.md#utcnow) template function as the resource name or as a part of the resource name. Changing the resource name creates a new deploymentScripts resource. It is good for keeping a history of script execution.
312312

313313
> [!NOTE]
314314
> The utcNow function can only be used in the default value for a parameter.

articles/azure-resource-manager/templates/template-functions-date.md

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ description: Describes the functions to use in an Azure Resource Manager templat
44
ms.topic: conceptual
55
ms.date: 04/06/2020
66
---
7-
# String functions for ARM templates
7+
# Date functions for ARM templates
88

9-
Resource Manager provides the following functions for working with strings in your Azure Resource Manager (ARM) templates:
9+
Resource Manager provides the following functions for working with dates in your Azure Resource Manager (ARM) templates:
1010

1111
* [dateTimeAdd](#datetimeadd)
1212
* [utcNow](#utcnow)
@@ -21,8 +21,8 @@ Adds a time duration to a base datetime value.
2121

2222
| Parameter | Required | Type | Description |
2323
|:--- |:--- |:--- |:--- |
24-
| base | Yes | string ([ISO 8601 timestamp format](https://en.wikipedia.org/wiki/ISO_8601)) | The starting datetime value for the addition. |
25-
| duration | Yes | string ([ISO 8601 duration format](https://en.wikipedia.org/wiki/ISO_8601#Durations)) | The time value to add to the base. It can be a negative value. |
24+
| base | Yes | string | The starting datetime value for the addition. Use [ISO 8601 timestamp format](https://en.wikipedia.org/wiki/ISO_8601). |
25+
| duration | Yes | string | The time value to add to the base. It can be a negative value. Use [ISO 8601 duration format](https://en.wikipedia.org/wiki/ISO_8601#Durations). |
2626
| format | No | string | The output format for the date time result. If not provided, the format of the base value is used. Use either [standard format strings](https://docs.microsoft.com/dotnet/standard/base-types/standard-date-and-time-format-strings) or [custom format strings](https://docs.microsoft.com/dotnet/standard/base-types/custom-date-and-time-format-strings). |
2727

2828
### Return value
@@ -74,6 +74,60 @@ When the preceding template is deployed with a base time of `2020-04-07 14:53:14
7474
| subtract9Days | String | 3/29/2020 2:53:14 PM |
7575
| add1Hour | String | 4/7/2020 3:53:14 PM |
7676

77+
The next example template shows how to set the start time for an Automation schedule.
78+
79+
```json
80+
{
81+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
82+
"contentVersion": "1.0.0.0",
83+
"parameters": {
84+
"omsAutomationAccountName": {
85+
"type": "string",
86+
"defaultValue": "demoAutomation",
87+
"metadata": {
88+
"description": "Use an existing Automation account."
89+
}
90+
},
91+
"scheduleName": {
92+
"type": "string",
93+
"defaultValue": "demoSchedule1",
94+
"metadata": {
95+
"description": "Name of the new schedule."
96+
}
97+
},
98+
"baseTime":{
99+
"type":"string",
100+
"defaultValue": "[utcNow('u')]",
101+
"metadata": {
102+
"description": "Schedule will start one hour from this time."
103+
}
104+
}
105+
},
106+
"variables": {
107+
"startTime": "[dateTimeAdd(parameters('baseTime'), 'PT1H')]"
108+
},
109+
"resources": [
110+
{
111+
"name": "[concat(parameters('omsAutomationAccountName'), '/', parameters('scheduleName'))]",
112+
"type": "microsoft.automation/automationAccounts/schedules",
113+
"apiVersion": "2015-10-31",
114+
"location": "eastus2",
115+
"tags": {
116+
},
117+
"properties": {
118+
"description": "Demo Scheduler",
119+
"startTime": "[variables('startTime')]",
120+
"isEnabled": "true",
121+
"interval": 1,
122+
"frequency": "hour"
123+
}
124+
}
125+
],
126+
"outputs": {
127+
}
128+
}
129+
```
130+
77131
## utcNow
78132

79133
`utcNow(format)`

articles/azure-resource-manager/templates/template-functions-string.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1869,7 +1869,7 @@ The following example shows how to create a unique name for a storage account ba
18691869
...
18701870
```
18711871

1872-
If you need to create a new unique name each time you deploy a template, and don't intend to update the resource, you can use the [utcNow](#utcnow) function with uniqueString. You could use this approach in a test environment. For an example, see [utcNow](#utcnow).
1872+
If you need to create a new unique name each time you deploy a template, and don't intend to update the resource, you can use the [utcNow](template-functions-date.md#utcnow) function with uniqueString. You could use this approach in a test environment. For an example, see [utcNow](template-functions-date.md#utcnow).
18731873

18741874
### Return value
18751875

articles/azure-resource-manager/templates/template-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Resource Manager provides several functions for making comparisons in your templ
7676

7777
Resource Manager provides the following functions for working with dates.
7878

79-
* [dateTimeAdd](template-functions.date.md#datetimeadd)
79+
* [dateTimeAdd](template-functions-date.md#datetimeadd)
8080
* [utcNow](template-functions-date.md#utcnow)
8181

8282
## Deployment value functions

0 commit comments

Comments
 (0)