Skip to content

Instantly share code, notes, and snippets.

View kasunkv's full-sized avatar
💭
I may be slow to respond.

Kasun Kodagoda kasunkv

💭
I may be slow to respond.
View GitHub Profile
@kasunkv
kasunkv / tags-other-resource.ps1
Created January 4, 2019 12:32
Add Tags to Azure Resource using Azure CLI
# Add tag to any other supported Azure Resource
az resource tag --tags Owner="Kasun Kodagoda" --resource-group "Tags-PRD-Web" --name kvktagsprdweb --resource-type "Microsoft.Web/sites"
@kasunkv
kasunkv / add-update-tags.sh
Created January 4, 2019 13:53
Add/Update tags using Azure CLI
result=$(az resource show --resource-group "Tags-PRD-Web" --name kvktagsprdweb --resource-type "Microsoft.Web/sites" --query tags)
tags=$(echo $result | tr -d '"{},' | sed 's/: /=/g')
az resource tag --tags $tags Owner="Kasun Kodagoda" --resource-group "Tags-PRD-Web" --name kvktagsprdweb --resource-type "Microsoft.Web/sites"
@kasunkv
kasunkv / azure-pipelines.yml
Created March 5, 2019 17:33
azure-pipelines.yml
trigger:
branches:
include:
- master
- refs/tags/*
pr:
- master
pool:
vmImage: 'VS2017-Win2016'
@kasunkv
kasunkv / install.sh
Created March 6, 2019 15:43
Install kubectl using Azure CLI
# Install kubectl using Azure CLI
az aks install-cli
@kasunkv
kasunkv / create-rg.sh
Created March 6, 2019 15:49
Login and Create Resource Group on Azure.
# Login to Azure using the CLI
az login --use-device-code
# Create the resource group for the AKS cluster
az group create --name "aks-demo-rg" --location "southeastasia"
@kasunkv
kasunkv / create-policy.ps1
Created March 10, 2019 07:28
Create Azure Policy Assignment using Azure PowerShell
# Login to Azure Subscription
Login-AzureRmAccount
# Get a reference to the resource group
$rg = Get-AzureRmResourceGroup -Name "az-policy-rg"
# Get a referecen to the Azure Policy Definition
$policyDef = Get-AzureRmPolicyDefinition | Where-Object { $_.Properties.DisplayName -eq "Audit VMs that do not use managed disks" }
# Create the new Policy Assignment for the Resource Group
@kasunkv
kasunkv / create-policy.ps1
Last active March 10, 2019 07:38
Creating a Policy Assignment using Azure CLI
# Login to Azure
az login --use-device-code
# Get Regerence to Resource Group
$rgId = az group show --name "az-policy-rg" --query "id" --output tsv
# Get Reference to the Azure Policy Definition
$policyName = az policy definition list --query "[?displayName == 'Audit use of classic virtual machines'].name" --output tsv
# Assign the policy
@kasunkv
kasunkv / enable-resource-provider.ps1
Created March 10, 2019 16:35
Enable Azure Resource Provider using PowerShell
# Login to Azure Subscription
Login-AzureRmAccount
# Check the registration Status of the Resource Provider
Get-AzureRmResourceProvider -ListAvailable | Where-Object { $_.ProviderNamespace -eq "Microsoft.Compute" }
# Register the Microsoft.Compute Resource Provider
Register-AzureRmResourceProvider -ProviderNamespace "Microsoft.Compute"
@kasunkv
kasunkv / enable-resource-provider.sh
Last active March 10, 2019 16:40
Enable Azure Resource Provider using Azure CLI
# Login to Azure
az login --use-device-code
# Check the registration Status of the Resource Provider
az provider list --query "[?namespace == 'Microsoft.Compute']" --output table
# Register the Microsoft.Compute Resource Provider
az provider register --namespace "Microsoft.Compute"
var oneService = new ServiceDescriptor(typeof(IOneService), typeof(OneService), ServiceLifetime.Scoped);
services.Add(oneService);