Implement Pipeline Support by making proper use of begin, process and end blocks in PowerShell functions

Of many things that make PowerShell stand apart in the world of scripting languages, perhaps two are most fundamental to it: first, its treats everything as Objects and second, the ability to pipe objects from one cmdlet to another. Using this capability, we can effortlessly link multiple cmdlets together. Doing this will also throttle the amount of memory that is being allocated (in most cases) that the current session is using for the commands. So, its very natural that you would want to implement pipeline support for your own function, that you just wrote.
Continue reading “Implement Pipeline Support by making proper use of begin, process and end blocks in PowerShell functions”

Write Advanced functions in PowerShell using various Write Cmdlets

PowerShell has become de-facto tool of choice for automation in Microsoft world from long time and slowly it is winning over hearts of the Linux administrators as well. Just like with other programming languages, there are many ways to do the same thing in PowerShell. However they differ in little subtle ways. You may or may not notice them in your day to day usage, but if you learn those subtleties, you can quickly improve the performance and results of your automation. This blog post is about one of the such cases only.
Continue reading “Write Advanced functions in PowerShell using various Write Cmdlets”

Store the app secrets in Azure Key Vault and use during Azure Pipelines

You can easily store your environment related secrets in the Azure Pipelines releases as variables and mark them as secrets which will encrypt and hide them. So anyone having access to the release definition would be not able to view them. Most of the times, it suffices as once set, they become encrypted and can not be viewed in text form.

However, sometimes it may happen that the person who keeps the secret would not be the same person as who is creating the release definition. Think of that as a way of segregating the responsibilities between the two. Also, it may be possible that the person who has provisioned the environment is not comfortable to share the secrets with anyone in plain text. After all, the best way to keep a secret is not to tell anyone about it. This is where the Azure Key Vault fits in very nicely. It can be used to store and transfer the secrets/certificates needed for your environment in a secure way.
Continue reading “Store the app secrets in Azure Key Vault and use during Azure Pipelines”

Remove old docker images from Azure Container Registry

As part of the Continuous Integration process, new builds are generated which contains certain enhancements or modification or bugfixes. For a containerized application deployment, docker images are created as part of builds which then needs to be uploaded to one of the container registries. Over the time, the registry will get filled up. Also as one use more and more space on the container registry, one needs to pay more and more.

There are no inbuilt commands or utilities provided by Docker for this. You have to write complex scripts for doing it. Fortunately, in latest round of the Azure CLI update, Microsoft has added some commands to do this. However, it can be cumbersome to select and remove docker images one at a time.  Continue reading “Remove old docker images from Azure Container Registry”

Azure RM Resource group deployment failed with error: Creating the deployment xx would exceed the quota of ‘800’.

Recently while deploying the source code using our CI/CD pipelines, we have got this error:

There were errors in your deployment. Error code: DeploymentQuotaExceeded.

2018-05-30T04:52:38.0042831Z ##[error]Creating the deployment ‘azuredeploy-20180430-045236-1abd’ would exceed the quota of ‘800’. The current deployment count is ‘800’, please delete some deployments before creating a new one. Please see https://aka.ms/arm-deploy for usage details.

2018-05-30T04:52:38.0051084Z ##[error]Task failed while creating or updating the template deployment.

One of the steps used by our release pipelines uses ARM template to make sure that resource being targeted has required azure configuration.
Continue reading “Azure RM Resource group deployment failed with error: Creating the deployment xx would exceed the quota of ‘800’.”