Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

powershell - Azure CLI commands not working inside azure function apps (portal)

I have powershell scripts which is running locally.But those scripts not running insite function apps > powershell (windows) machine.

az login --service-principal -u $ServicePrincipalId -p $ServicePrincipalPass --tenant $ServicePrincipalTenant

Getting below when i run the script

ERROR: The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program.

since i dont have az cli installed in the windows machine, i have added below line to install az command in my script.

Install-Module -Name Az -AllowClobber  -Scope CurrentUser

Getting access issue while installing the az.

2019-06-11T12:42:59.698 [Warning] WARNING: InternalWebProxy: Could not find a part of the path 'D:Program Files (x86)SiteExtensionsFunctions2.0.1250732bitworkerspowershell
untimeswin-x86lib
etcoreapp2.1
ef'.
2019-06-11T12:42:59.843 [Warning] WARNING: Win32Helpers: Could not find a part of the path 'D:Program Files (x86)SiteExtensionsFunctions2.0.1250732bitworkerspowershell
untimeswin-x86lib
etcoreapp2.1
ef'.
2019-06-11T12:43:05.023 [Warning] WARNING: User declined to install module (Az).

even -Force is not working. need to know what is causing the issue.

Note :- The script is perfectly running in local windows machine. the issue is when try to run on portal > functionapp> timertrigger

Attaching azure function app creating with windows machine

enter image description here

Getting error after adding cli folder into kudu

> 2019-06-13T12:29:40.510 [Error] ERROR:   File
> "C:UsersVSSADM~1AppDataLocalTemppip-install-68v0_w99azure-cli-coreazureclicorecommands\__init__.py", line 523, in execute Microsoft.Azure.WebJobs.Script.Rpc.RpcException :
> Result: ERROR:   File
> "C:UsersVSSADM~1AppDataLocalTemppip-install-68v0_w99azure-cli-coreazureclicorecommands\__init__.py", line 523, in execute Exception:   File
> "C:UsersVSSADM~1AppDataLocalTemppip-install-68v0_w99azure-cli-coreazureclicorecommands\__init__.py", line 523, in execute

kudu console

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

As the error shows that you do not install the Azure CLI in the environment. To install the Azure CLI, a possible way is to copy the whole CLI directory that you installed in the local machine to your function KUDU path /home.

In the test, the copy path in the function KUDU is D:/home/CLI2/.

Test code:

D:/home/CLI2/wbin/az.cmd login --service-principal -u 'xxxxxx' -p 'xxxxxx' --tenant 'xxxxxx' | Write-Host

The screenshot of the output:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...