Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Run Azure CLI

Open giorgited opened this issue 8 years ago • 4 comments

Is it possible to use azure cli within Azure Functions?

I am wanting to run a command az acs scale ... on a timely bases from Azure Functions.

giorgited avatar Jan 05 '18 22:01 giorgited

You can use PowerShell Azure functions and run Azure Powershell commands once you logged in with ServicePrincipal credentials. Store your service principal user and password in Function App's AppSettings Sample code for logging in from command line:

$secstr = New-Object -TypeName System.Security.SecureString $password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)} $cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $env:spusername, $secstr

Login-AzureRmAccount -Credential $cred -ServicePrincipal -TenantId 72f988bf-86f1-41af-91ab-2d7cd011db47 Write-Output "PowerShell Timer trigger function logged in";

Once logged in, you should be able to run any other commands

pragnagopa avatar Jan 08 '18 20:01 pragnagopa

Closing this issue. Please reactivate if you still need help.

pragnagopa avatar Jan 08 '18 20:01 pragnagopa

@pragnagopa can you execute azure cli within Azure Functions?

tiny-dancer avatar Dec 02 '18 20:12 tiny-dancer

https://github.com/Azure/azure-functions-powershell-worker/issues/221 image

AbhishekHumagain avatar Jul 25 '19 09:07 AbhishekHumagain