-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update readme for -pre and -post TestResource scripts (#28800)
Co-authored-by: Christopher Scott <[email protected]>
- Loading branch information
1 parent
19c1dcb
commit 96b8f8f
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,49 @@ setx KEYVAULT_SKU ${env:KEYVAULT_SKU} | |
setx AZURE_KEYVAULT_URL ${env:AZURE_KEYVAULT_URL} | ||
``` | ||
|
||
### Pre- and Post- Scripts | ||
|
||
Sometimes creating test resources requires either some work to be done prior to or after the main test-resources.json script is executed. | ||
For these scenarios a `test-resources-pre.ps1` or `test-resources-post.ps1`, respectively, can be created in the same folder as the `test-resources.json` file. | ||
|
||
For example, it may be necessary to create artifacts prior to provisioning the actual resource, such as a certificate. | ||
Typically the created artifact will need to be passed to `test-resources.json` to be used in the ARM template or as output (or both). | ||
|
||
Below is an example of how `$templateFileParameters` can be used to pass data from the `pre-` script to `test-resources.json`. | ||
|
||
**Snippet from `test-resources-pre.ps1`** | ||
```powershell | ||
$cert = New-X509Certificate2 -SubjectName '[email protected], CN=Azure SDK, OU=Azure SDK, O=Microsoft, L=Frisco, S=TX, C=US' -ValidDays 3652 | ||
# Create new entries in $templateFileParameters | ||
$templateFileParameters['ConfidentialLedgerPrincipalPEM'] = Format-X509Certificate2 -Certificate $cert | ||
$templateFileParameters['ConfidentialLedgerPrincipalPEMPK'] = Format-X509Certificate2 -Type Pkcs8 -Certificate $cert | ||
``` | ||
|
||
**Snippet from the corresponding `test-resources.json`.** | ||
|
||
Note that the values present in `$templateFileParameters` will map to parameters of the same name. | ||
```json | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"_comment": "Other required parameters would go here... (this is not part of the actual test-resources.json)", | ||
"ConfidentialLedgerPrincipalPEM": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "The certificate to configure as a certBasedSecurityPrincipal." | ||
} | ||
}, | ||
"ConfidentialLedgerPrincipalPEMPK": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "The certificate to configure as a certBasedSecurityPrincipal." | ||
} | ||
} | ||
}, | ||
} | ||
``` | ||
|
||
### Cleaning up Resources | ||
|
||
By default, resource groups are tagged with a `DeleteAfter` value and date according to the default or specified | ||
|