From b081b4eaa4d99012c22af7bebde1b5c47d6bdc9a Mon Sep 17 00:00:00 2001 From: DakotaCondos <79940799+DakotaCondos@users.noreply.github.com> Date: Tue, 7 Apr 2026 12:42:25 -0700 Subject: [PATCH 1/3] Implement Assignment 1 Azure OIDC workflow --- .github/workflows/Assignment1.yml | 32 ++++++++++++++++++++++ Assignment1/Assignment1.ps1 | 45 +++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 .github/workflows/Assignment1.yml create mode 100644 Assignment1/Assignment1.ps1 diff --git a/.github/workflows/Assignment1.yml b/.github/workflows/Assignment1.yml new file mode 100644 index 0000000..baad311 --- /dev/null +++ b/.github/workflows/Assignment1.yml @@ -0,0 +1,32 @@ +name: Assignment1 + +on: + workflow_dispatch: + push: + branches: + - Assignment1 + +permissions: + id-token: write + contents: read + +jobs: + list-resources: + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Azure login with OIDC + uses: azure/login@v2 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + + - name: Run PowerShell script + uses: azure/powershell@v2 + with: + inlineScript: ./Assignment1/Assignment1.ps1 + azPSVersion: "latest" \ No newline at end of file diff --git a/Assignment1/Assignment1.ps1 b/Assignment1/Assignment1.ps1 new file mode 100644 index 0000000..68d4c36 --- /dev/null +++ b/Assignment1/Assignment1.ps1 @@ -0,0 +1,45 @@ +# Assignment 1: Create and Delete Azure Storage Account + +# Define variables +$subscription_id = "98ef8437-66f2-4a03-9d1a-cf7057d27d9c" +$resourceGroupName = "assignment1-rg" +$location = "westus2" +$tempStorageName = ("a1temp" + (Get-Random -Maximum 99999999)) + +# Connect to Azure account +Write-Host "Connecting to Azure account..." +Set-AzContext -SubscriptionId $subscription_id | Out-Null + +# List resources before creating storage account +Write-Host "Listing resources before create:" +Get-AzResource | +Select-Object Name, ResourceGroupName, ResourceType, Location | +Format-Table -AutoSize + +# Create a temporary storage account +Write-Host "Creating temp storage account: $tempStorageName" +New-AzStorageAccount ` + -ResourceGroupName $resourceGroupName ` + -Name $tempStorageName ` + -Location $location ` + -SkuName Standard_LRS ` + -Kind StorageV2 | Out-Null + +# List resources after creating storage account +Write-Host "Listing resources after create:" +Get-AzResource | +Select-Object Name, ResourceGroupName, ResourceType, Location | +Format-Table -AutoSize + +# Delete the temporary storage account +Write-Host "Deleting temp storage account: $tempStorageName" +Remove-AzStorageAccount ` + -ResourceGroupName $resourceGroupName ` + -Name $tempStorageName ` + -Force + +# List resources after deleting storage account +Write-Host "Listing resources after delete:" +Get-AzResource | +Select-Object Name, ResourceGroupName, ResourceType, Location | +Format-Table -AutoSize \ No newline at end of file From 79f529af0a283f428ff287cb84368ead1fcb05fa Mon Sep 17 00:00:00 2001 From: DakotaCondos <79940799+DakotaCondos@users.noreply.github.com> Date: Tue, 7 Apr 2026 12:55:26 -0700 Subject: [PATCH 2/3] Adjust az login version --- .github/workflows/Assignment1.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Assignment1.yml b/.github/workflows/Assignment1.yml index baad311..763a5c5 100644 --- a/.github/workflows/Assignment1.yml +++ b/.github/workflows/Assignment1.yml @@ -19,7 +19,7 @@ jobs: uses: actions/checkout@v4 - name: Azure login with OIDC - uses: azure/login@v2 + uses: azure/login@v3 with: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} From a5672de33b75979d859f3e690ae04f3d8ada6968 Mon Sep 17 00:00:00 2001 From: DakotaCondos <79940799+DakotaCondos@users.noreply.github.com> Date: Tue, 7 Apr 2026 13:11:32 -0700 Subject: [PATCH 3/3] workflow enable-AzPSSession: true --- .github/workflows/Assignment1.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/Assignment1.yml b/.github/workflows/Assignment1.yml index 763a5c5..dee7451 100644 --- a/.github/workflows/Assignment1.yml +++ b/.github/workflows/Assignment1.yml @@ -24,6 +24,7 @@ jobs: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + enable-AzPSSession: true - name: Run PowerShell script uses: azure/powershell@v2