Therefore, we might be able to build more robust ARM templates. As an extreme example, consider this test. With this, we can test how ARM template deployment works, and what sort of results we can expect after the run. The Describe, Context and It keywords might look like a static DSL, but theyre actually just PowerShell cmdlets that take a string and a script block as a parameter - the tests themselves are only 'materialized' (for want of a better word) when the script runs. So far, we have walked through how to test ARM template deployment without actually deploying it, using Pester, which is an awesome tool for our PowerShell scripting. Now, our CI/CD pipeline picks up the change and triggers the Azure PowerShell task to run this test. Then add the PowerShell script stated right above. In this case, we must login to Azure Resource Manager first, using a service principal. If we’re not using VSTS, it’s doubtful that it has such feature. It would be even easier with the Pester extension. If we’re using VSTS, it’s pretty straightforward – use Azure PowerShell Task. Now, we can confirm that all tests have been passed. If we use the debugging mode while running the cmdlet and capture those debugging messages, we might be able to get some clues. So you code along, happy in the knowledge that you can focus on the problem and free up some mental memory to work on the problem at hand. Therefore, merely running Test-AzureRmResourceGroupDeployment won’t help much for testing. Once you start Pester-ing your tests, it gets easier since you know that any unwanted bugs introduced by your changes will be captured and raised up to you. What makes the composition worse is those template functions are nested, which possibly results in missing some of opening or closing parentheses, and single quotation marks at some stage. In many cases, composing ARM templates need many template functions like concat(), parameters(), variables(), resourceId() and so forth. The Test-AzureRmResourceGroupDeployment doesn’t give us any indication to sort out this situation. How can we ensure this concatenation has been successful? If there are more parameters involved in those naming and other configurations, our lives would be more complicated. For example, with the ARM template above, the resource name is a concatenation of both parameters, logicAppName1 and logicAppName2. Even if the ARM template has been deployed successfully, we still can’t guarantee that the deployed Azure resources are correctly configured or not. Problemsįrom this point, we only know that the ARM template deployment ITSELF will be successful. However, you could easily pull them from a text file, or a database. I have a hard coded list of cluster names. If we are going to test that we’re in our expected configuration, we need to record what that configuration looks like. As the ARM template above is valid and test is successful, which returns NOTHING. Step 1 Store the current resource owners.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |