Skip to main content

Posts

Showing posts with the label DevOps

Az DevOps CLI - Fetch all Pull Requests assigned to a user

I wrote a sample PowerShell code snippet to crawl across all opened Pull requests in multiple repositories inside an Azure DevOps project and list the ones out where myself or the team/group I am part of assigned as a reviewer. End result is this:

Az DevOps CLI : Query Release(s) definition for a Task status

Someone, asked me at work if I could generate a list of Release pipelines definitions which did not have a specific task ( AzSK SVT task ) missing or disabled. This was more for an internal audit purpose and can definitely be built upon. I recently read that Az CLI got an extension support for Az DevOps . Please read on the GitHub repository on how to install this extension for Az CLI. Time to put this to try. Below gist describes the steps I used in pwsh (PowerShell Core) with Az CLI & DevOps extension installed. The above script should be self explanatory (read the comments). Please leave a comment if you have any queries.

Python : Exploring Objects similar to PowerShell

To be fair Python's REPL mode allows you to explore objects pretty easy. But since PowerShell has been my first language, I often tend to crib for similar experience. P.S. - I do know that PowerShell language specs picked up quite many things from Python. Also, Python is my goto language on Linux platform as well. So back to cribbing, I tend to miss most the exploring aspects of  PowerShell e.g. Get-Member and Format-* cmdlets until one day I sat down and wrote few functions in Python to give me a similar experience.

Notes on Azure + PowerShell + Account SAS

Well, below are my notes on using account Shared access signatures in Azure using Azure PowerShell modules. Theory Let's get the basics out of the way first. A shared access signature is a way to delegate access to resources in a storage account, without sharing the storage account keys. SAS gives us granular control over the delegated access by : Specifying the start and expiry time. Specifying the permissions granted e.g Read/Write/Delete Specifying the Source IP address where the requests will originate from. Specifying the protocol to be used e.g HTTP/HTTPS.

PowerShell + .psd1 files - decouple environment configuration data from code

What is environment configuration data? Well, you might have heard the term 'configuration data' in usage with PowerShell DSC. The case for using configuration data is wherein all the input arguments are abstracted from the code being written so that this configuration data can be generated on the fly and passed to the underlying scripts or framework like DSC. For some of our solutions being deployed at the customer site, we require a lot of input parameters e.g. different network subnets for management and storage networks, AD/DNS information etc. Adding all these parameters to our input argument collector script was an error prone and tedious task since there were far too many input arguments. So instead of having a file to specify all input arguments was the preferred method. This also helped us while troubleshooting the deployments since a local copy of the input arguments always persisted.

PowerShell + AD + Pester : create new user using template Part 2

It seems like it has taken me forever to post this one. I had this one almost ready but then I asked few questions around, read a lot of posts and had to rewrite the pieces of the post, to sum it all it has been an eye opening when trying to test PowerShell code which interacts with Infrastructure. Below pic depicts my state at this point ( revelation to a whole new world). [ credits : movie "V for Vendetta"] In the last post , we laid the foundation for our Function. Go back and check the code their as we start from where we left off. In this post we dive straight into the third context for our Pester tests : Context  "User Creation"    It  should return Object when -Passthru specified (New addition)   It  should take OU Path from template User.    It  should only copy allowed set of attributes from the User (by default).    It  should allow copying a subset of allowed set of attributes .     Note - ...

PowerShell + Azure + Python : Use Project Custom Settings

Background First to set up the background [bit reaching on the Dev side] on the post, quick introduction to what is an Azure Cloud service along with some terms Dev like to throw around: Cloud Service : PaaS offering , running VMs on Microsoft Azure. You have control over these VMs as you can remote into them and customize them to run your apps. A typical cloud service contains: Web Role - Windows Server running IIS on top of it. Worker Role - Windows Server. Now using Visual Studio one can configure the Cloud Service as per ones need (Check Resources at the bottom). There are typically 2 files in your project definition which need tweaking (source : MSDN - link in Resources section) : ServiceDefinition.csdef   :  The service definition file defines the runtime settings for your cloud service including what roles are required, endpoints, and virtual machine size. None of the data stored in this file can be changed when your role is running . ServiceConfigur...

PowerShell + Azure : Validate ResourceGroup Tags

Recently been working on some DevOps stuff in Azure using Python & PowerShell, so would be doing few posts revolving around that. Why I have added the below pic ? Python is what I have been picking from the Dev world (currently) and PowerShell is what I have picked from the Ops world. In Azure Resource Manager, one can add tags to the Resource Groups (check out the new Azure Portal to explore ResourceGroups ). Last week had to script a way to check that there is a Tag on the resource group with a valid set of values. Python Azure SDK doesn't yet support Azure Resource Manager operations so had to turn to the Ops side (PowerShell way). Don't worry if you have no idea what a tag is, the validation code is pretty neat. For Example - the Resource Group should have a tag named "Environment" on it with the valid values of "Dev","QA" & "Prod" .