Azure Bat Script

Handian Sudianto 4,451 Reputation points


I have script to list all web app, but we still need manually connect to the azure via power shell then execute the script. Can we make bat script to automate this process?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,356 questions
{count} votes

Accepted answer
  1. Sedat SALMAN 13,345 Reputation points

    if you do not want any prompt to connect to Azure
    you can create a script and pass a connection parameter (this is generally not accepted as a safe method
    but if you think you can save these files in a secure way you can insert connection parameters to the script as follows)

    # Define your service principal credentials
    $azureAppId="<Your Azure App ID>"
    $azurePassword="<Your Azure Password>"
    $azureTenantId="<Your Azure Tenant ID>"
    # Create a PS credential object
    $psCred = New-Object System.Management.Automation.PSCredential($azureAppId, (ConvertTo-SecureString $azurePassword -AsPlainText -Force))
    # Login to Azure
    Connect-AzAccount -Credential $psCred -Tenant $azureTenantId -ServicePrincipal
    # Get all web apps
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Luke Murray 10,896 Reputation points MVP

    Not with bat directly, but you could download and connect to the Azure API via curl -

    Although you may be better off to use PowerShell, and Invoke-Restmethod, or the Azure powershell commandlets.

    0 comments No comments