Skip to content

Instantly share code, notes, and snippets.

View gsuttie's full-sized avatar

Gregor Suttie gsuttie

View GitHub Profile
#Login to Azure
Login-AzureRmAccount
#List all Resources within the Subscription
$Resources = Get-AzureRmResource
#For each Resource apply the Tag of the Resource Group
Foreach ($resource in $Resources)
{
$Rgname = $resource.Resourcegroupname
# Python example Azure Pipeline
trigger:
- azure-pipelines
- master
jobs:
- job: Ubuntu_testing
# https://docs.microsoft.com/en-us/azure/devops/pipelines/yaml-schema?view=azure-devops&tabs=schema#pool
{
"Name": "Virtual Machine Operator (Custom)",
"Id": null,
"IsCustom": true,
"Description": "Allows to start and stop (deallocate) Azure VMs",
"Actions": [
"Microsoft.Compute/*/read",
"Microsoft.Compute/virtualMachines/deallocate/action",
"Microsoft.Compute/virtualMachines/start/action"
],
@gsuttie
gsuttie / gist:3b339a128eac2613d0eafa025bb6f5db
Last active July 8, 2020 18:38
PowerShell Script to Create Azure Custom RBAC Role
CD $HOME
wget https://gist.githubusercontent.com/gsuttie/9fc7736ebf06371a601218902adee770/raw/9d007ccb7fc367bf26a3b3d6c71fa11b3b5ffa85/customRoleDefinition.json
$subscription_id = (Get-AzContext).Subscription.id
(Get-Content -Path $HOME/customRoleDefinition.json) -Replace 'SUBSCRIPTION_ID', $subscription_id |
Set-Content -Path $HOME/customRoleDefinition.json
New-AzRoleDefinition -InputFile ./customRoleDefinition.json
@gsuttie
gsuttie / gist:92ed20b1cd1f2e0d87e3e2e090ce4708
Created September 16, 2020 17:38
retrudurablefunction3times
[FunctionName("A_MakeCall2")]
public static string MakeCall2([ActivityTrigger] CallInfo callInfo, [Table("MadeCalls2", "AzureWebJobStorage")] out CallDetails calldetails, ILogger log)
{
log.LogWarning($"MakeCall {callInfo.Numbers}");
var madeCallId = Guid.NewGuid().ToString("N");
calldetails = new CallDetails
{
PartitionKey = "MadeCalls",
[FunctionName("O_PeriodicTask")]
public static async Task<int> PeriodicTask([OrchestrationTrigger] IDurableOrchestrationContext ctx, ILogger log)
{
var timesRun = ctx.GetInput<int>();
timesRun++;
if (!ctx.IsReplaying)
log.LogWarning($"Starting the PeriodicTask activity {ctx.InstanceId}, {timesRun}");
await ctx.CallActivityAsync("A_PeriodicActivity", timesRun);
var nextRun = ctx.CurrentUtcDateTime.AddSeconds(30);
[FunctionName("O_PeriodicTask3")]
public static async Task<string> PeriodicTask3([OrchestrationTrigger] IDurableOrchestrationContext context, ILogger log)
{
var waitBetweenTries = TimeSpan.FromSeconds(100); // 3 tries in 5 minutes
var phoneNumbers = await context.CallActivityAsync<string[]>("A_GetNumbersFromStorage", null);
var callTime = context.CurrentUtcDateTime;
try
{
foreach (var phoneNumber in phoneNumbers)
param location string
param containersRGMI string
@description('Create a brand new User Assigned Managed Identity')
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = {
name: containersRGMI
location: location
}