GithubHelp home page GithubHelp logo

blog-v2's Introduction

I'm Pains, yes that's my last name and I build software stuff. Oh, I also sometimes blog about the stuff I build at blog.lpains.net. I've been coding for way too long now so a day without code is just not a good day. How can it be?

I live in the USA, was born in Brazil and miss living in Australia. Confusing? Yes.

I code anything, really. But there is nothing better than designing an enterprise scale architecture and see the many pieces working nicely together and evolving. I've designed multi-billion dollar software systems and that was fun but I lost nearly all my hair in the process.

What else do I do? I go home and code some more. However, I got some completely unrelated passions. For instance, I am:

  • Kung Fu instructor. I studied under Grand Master Lopes in Kung Fu Taisan.
  • Taekwondo Black Belt
  • Snowboarder. Turn up the music and hit the slopes.
  • Volleyball player. I really wanted to play professional, but apparently you need to be really good and ridiculous tall for that...

Some GitHub stats:

jlucaspains' GitHub Stats jlucaspains' GitHub Top Languages

Blog posts

  1. Jul 5, 2024 - GO REST Template Major Changes
  2. May 31, 2024 - Sharp Cooking v1.11.0 released!
  3. May 27, 2024 - Running Agile projects in GitHub Projects - 2024 review
  4. May 5, 2024 - Introducing documorph
  5. Apr 7, 2024 - Streamlining App Role Setup with Azure Entra: A Step-by-Step Guide

blog-v2's People

Contributors

jlucaspains avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

blog-v2's Issues

Adding roles to Azure Entra app registration and user groups

Script:

[CmdletBinding()] param ()

$RolesToAddFile = "./NewAppRole.json"
$AppNames = @(
    "OrdersApi",
    "PeopleApi"
)
$Roles = @{
    "Administrators" = "administrator"
    "Developers" = "developers"
    "Users" = "users"
}
$Envs = @(
    @("Dev", "dev"),
    @("QA", "qa")#,
    #@("Prod", "prod"))
)
foreach ($AppName in $AppNames) {
    Write-Host "Processing $($AppName)..."
    foreach ($Env in $Envs) {
        $FullAppName = "$($AppName)-$($Env[0])"
        Write-Host "Processing $FullAppName..."
        $appObjectId = (az ad app list --display-name $FullAppName --query "[0].id" -o tsv)
        $appSPObjectId = $(az ad sp list --display-name $FullAppName --query '[0].id' -o tsv)
        
        $jsonData = Get-Content -Path $RolesToAddFile | ConvertFrom-Json

        Write-Verbose "App Object Id: $appObjectId"
        Write-Verbose "App Service Principal Object Id: $appSPObjectId"

        Write-Host "Creating unique list of roles to update..."
        $existingAppRegRolesJson = (az ad app list --display-name $FullAppName --query "[0].appRoles")
        Write-Verbose ($existingAppRegRolesJson | ConvertTo-Json)
        $existingAppRegRoles = $existingAppRegRolesJson | ConvertFrom-Json
        $mergedUniqueRoles = $existingAppRegRoles + $jsonData | Sort-Object -Property Id -Unique

        $appRoles = $mergedUniqueRoles | ConvertTo-Json
        Write-Verbose $appRoles

        $appRoles > "./TempRoles.json"

        Write-Host "Adding app registration roles..."
        az ad app update --id $appObjectId --app-roles "./TempRoles.json"

        $existingRoles = (az rest -m GET -u "https://graph.microsoft.com/v1.0/servicePrincipals/$appSPObjectId/appRoleAssignedTo") | ConvertFrom-Json

        Write-Verbose $existingRoles

        foreach ($role in $jsonData) {
            if ($null -eq $Roles[$role.Value]) {
                Write-Host "Role $($role.Value) is not defined in the script. Skipping..."
                continue;
            }

            $existingRole = $existingRoles.value | Where-Object { $_.appRoleId -eq $role.id }

            if ($null -ne $existingRole) {
                Write-Verbose $existingRole
                Write-Host "Binding already exist between $($role.Value) and group prefix-$($Env[1])-$($Roles[$role.Value])..."
                continue;
            }

            Write-Host "Binding $($role.Value) to group prefix-$($Env[1])-$($Roles[$role.Value])..."
            $RoleGuid = $role.id
            $groupId = (az ad group list --display-name "prefix-$($Env[1])-$($Roles[$role.Value])" --query "[0].id" -o tsv)

            $postBody = "{\""principalId\"": \""$groupId\"", \""resourceId\"": \""$appSPObjectId\"", \""appRoleId\"": \""$RoleGuid\""}"

            Write-Verbose $postBody

            az rest -m POST -u "https://graph.microsoft.com/v1.0/servicePrincipals/$appSPObjectId/appRoleAssignments" -b $postBody --headers "Content-Type=application/json"
        }
    }
    
    Write-Host "Finished procesing $($AppName)"
}

Roles.json:

[
    {
        "allowedMemberTypes": [
            "User"
        ],
        "description": "Can use all app features including write capabilities",
        "displayName": "Administrator",
        "id": "25909a57-ce45-49d3-b1f3-4b6f3d03d15a",
        "isEnabled": true,
        "origin": "Application",
        "value": "Administrator"
    },
    {
        "allowedMemberTypes": [
            "User"
        ],
        "description": "Can configure aspects the application but generally not make administrative changes",
        "displayName": "Developer",
        "id": "07470a96-716a-4688-92fd-6fb452f81202",
        "isEnabled": true,
        "origin": "Application",
        "value": "Developer"
    },
    {
        "allowedMemberTypes": [
            "User"
        ],
        "description": "Can view data and perform user level actions but not make administrative changes",
        "displayName": "User",
        "id": "3e87b7be-a276-4e85-add7-974e0d29fed8",
        "isEnabled": true,
        "origin": "Application",
        "value": "User"
    }
]

Bulk import work items in Azure DevOps with CSV

Dirty notes:

  1. Cannot save State (Depends on state)
  2. Cannot s ave Parent (Cannot insert nor update)
  3. Cannot add Links (Can "easily" do after the import in backlog and bulk add link)
  4. Cannot add Attachments

Sample csv:
Id,Work Item Type,Title,State,Description,Priority,Effort,Area Path,Iteration Path,Tags
5015,Product Backlog Item,"{Feature name}: Discovery",Sprint Committed,Long description goes here,1,5,MyArea,MyArea\Sprint 1,"MVP,UX"

Setup CosmosDB as a container in Windows

docker run `
    --publish 8081:8081 `
    --publish 10250-10255:10250-10255 `
    --interactive `
    --tty `
    -e AZURE_COSMOS_EMULATOR_IP_ADDRESS_OVERRIDE=127.0.0.1 `
    mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator:latest

Download the cert, install using certutil:

certutil -addstore "Root" "emulatorcert.pem"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.