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
# Separates each Terraform action into separate steps in the pipeline. | |
# Authorization token is exported in the first steps after logging into Azure using Az CLI. | |
# Script then exports information into environment variables. | |
trigger: | |
- main | |
pool: | |
vmImage: ubuntu-latest |
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
#!/usr/bin/env pwsh | |
#Requires -Version 7.2 | |
if ($env:SYSTEM_DEBUG -eq "true") { | |
$InformationPreference = "Continue" | |
$VerbosePreference = "Continue" | |
$DebugPreference = "Continue" | |
Get-ChildItem -Path Env: -Force -Recurse -Include * | Sort-Object -Property Name | Format-Table -AutoSize | Out-String | |
} |
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
trigger: | |
- main | |
pool: | |
vmImage: ubuntu-latest | |
variables: | |
- name: workingDirectory | |
value: '<folder containing terraform code>' |
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
terraform { | |
required_providers { | |
azurerm = { | |
source = "hashicorp/azurerm" | |
version = ">= 3.7" | |
} | |
azuredevops = { | |
source = "microsoft/azuredevops" | |
version = ">= 1.0" |
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
# Build information for access token | |
# Reference: https://learn.microsoft.com/graph/auth-v2-service#token-request | |
$credential = Get-Credential | |
$tenantId = "<tenant guid>" | |
$oauthUri = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token" | |
$tokenRequestBody = @{ | |
client_id = $credential.UserName | |
client_secret = $credential.GetNetworkCredential().Password |
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
{ | |
"properties": { | |
"displayName": "Deploy CanNotDelete Resource Lock on Resource Groups", | |
"description": "Creates a resource lock at the resource group level for preventing resource deletion.", | |
"mode": "all", | |
"metadata": { | |
"version": "1.0.0", | |
"category": "General" | |
}, | |
"parameters": {}, |
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
{ | |
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"parameters": { | |
"dataDiskCount": { | |
"type": "int", | |
"metadata": { | |
"description": "Number of data disks to add to the VM." | |
} | |
} |
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
# Define variables for the virtual network and subnet properties | |
$location = "westus2" | |
$name = 'prod' | |
$vnetName = "vnet-$name-$location-001" | |
$vnetPrefix = '10.20.0.0/16' | |
# Include as many subnets as you want to create as hashtables in the array | |
$subnets = @( | |
[PsCustomObject]@{Name = 'mgmt'; Prefix = '10.20.2.0/24'}, | |
[PsCustomObject]@{Name = 'web'; Prefix = '10.20.4.0/24'}, |
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
DynamicParam { | |
if ($ChannelType -eq 'Private') { | |
# Define parameter attributes | |
$paramAttributes = New-Object -Type System.Management.Automation.ParameterAttribute | |
$paramAttributes.Mandatory = $true | |
# Create collection of the attributes | |
$paramAttributesCollect = New-Object -Type ` | |
System.Collections.ObjectModel.Collection[System.Attribute] | |
$paramAttributesCollect.Add($paramAttributes) |
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
$userPhoneNumbers = Get-CsPhoneNumberAssignment -CapabilitiesContain UserAssignment -Top ([int]::MaxValue) | |
foreach ($number in $userPhoneNumbers) { | |
if ($null -ne $number.AssignedPstnTargetId) { | |
$user = Get-CsOnlineUser -Identity $number.AssignedPstnTargetId | |
} | |
else { | |
$user = [PSCustomObject]@{ | |
DisplayName = "Not Assigned" | |
UserPrincipalName = $null |
NewerOlder