Posted on Leave a comment

Authenticate to Azure management API using az cli

A quick an easy way to authenticate on Azure management API is to use az cli get-access-token command and use this as a Bearer token on your API calls.

Given that you want to access https://management.azure.com/subscriptions/api you can use:

$token =  az account get-access-token | ConvertFrom-Json

You can then get the access token with $token.accesstoken

Finally you can use this token as a Bearer token on your API calls

$headers = @{ Authorization = "Bearer $token.accesstoken" }
Posted on Leave a comment

Deploy App Service .zip website folder on Azure with cmd

In a recent scenario I had an app service on which I wanted to deploy a .zip package with the appropriate code.

My app service was based on .NET 6 backend and I created an emtpy REST api project to host the app service.

Command to deploy through az cli.

az webapp deploy --resource-group "app-service-rg" --name "geralexgr-webappstatic" --src-path C:\Users\galexiou\Desktop\netwebapp.zip --type zip

Result of deployment through az cli.

On Deployment center logs you can verify your deployment.

Then you can use your website url to get the content of the deployed site. For the .NET rest api default project I should have to get the

url/weatherforecast