I deployed Azure Storage account with Service Principal and Github actions like below:-
My git repo:-

I used below command from this link - Deploy Resource Manager templates by using GitHub Actions - Azure Resource Manager | Microsoft
Learn
to create a service principal with RBAC Contributor role assigned at
the Subscription level :-
Command:-
az ad sp create-for-rbac --name "myML" --role contributor
--scopes /subscriptions/
--sdk-auth
Output:-


Copied the json output in my Github Actions Secrets like below:-

I used the below ARM Template to create a Storage account:-
azuredeploy.json
"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0", "metadata": {
"_generator": {
"name": "bicep",
"version": "0.13.1.58284",
"templateHash": "13120038605368246703"
} }, "parameters": {
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Premium_LRS",
"Premium_ZRS",
"Standard_GRS",
"Standard_GZRS",
"Standard_LRS",
"Standard_RAGRS",
"Standard_RAGZRS",
"Standard_ZRS"
],
"metadata": {
"description": "Storage Account type"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "The storage account location."
}
},
"storageAccountName": {
"type": "string",
"defaultValue": "[format('store{0}', uniqueString(resourceGroup().id))]",
"metadata": {
"description": "The name of the storage account"
}
} }, "resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2022-09-01",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "StorageV2",
"properties": {}
} ], "outputs": {
"storageAccountName": {
"type": "string",
"value": "[parameters('storageAccountName')]"
},
"storageAccountId": {
"type": "string",
"value": "[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
} } }
Above code Reference:-
https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.storage/storage-account-create/azuredeploy.json
My YML Script for github action :-
Replace the Resource group name with the existing Resource group where you want to create your storage account in.
main.yml
on: [push]
name: Azure ARM
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# Checkout code
- uses: actions/checkout@main
# Log into Azure
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# Deploy ARM template
- name: Deploy ARM template
uses: azure/arm-deploy@v1
with:
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }}
resourceGroupName: siliconrg
template: ./azuredeploy.json
parameters: storageAccountType=Standard_LRS
# output containerName variable from template
- run: echo ${{ steps.deploy.outputs.containerName }}
The Github action ran successfully like below:-

And storage account got created in Azure Portal:-

References:-
Exercise - Deploy ARM templates as part of your CI/CD efforts with
GitHub Actions - Training | Microsoft
Learn