Cant find extension installed in azure web apps - azure

I have configured an azure web app for PHP with windows OS. I have installed "composer" (for PHP) extension through azure portal and I can see the extension installed.
I can access the batch file when I traverse to the path as well but when I search "where composer" from global paths, then it cant be found. What am I missing? Do I need to add this to env paths somewhere?

What am I missing? Do I need to add this to env paths somewhere?
No, env path is required. To test this i have created a webapp (PHP 7.4, running on windows OS) and ran the below WHERE cmdlet in the below format and able to find the installed extension.
WHERE /R c:\home\SiteExtensions *.bat or WHERE /R c:\home\SiteExtensions composer*
Here is the sample output screenshot for reference:

Related

How to install composer globally on a Linux PHP app service?

I have an app service for my PHP 8.0 application. Azure will only allow me to use Linux which is fine, but I'm having trouble installing composer globally.
Because only files inside of /home are persisted I'm not sure where I can place the resulting composer.phar file, in such a way that it is included in the PATH, and I can't find any relevant documentation, only relevant discussion I could find was this: https://learn.microsoft.com/en-us/answers/questions/3638/installing-composer-on-azure-app-service.html but it still didn't help.
Could anyone tell me either where to put composer.phar or whether there's a way to edit my path to point towards /home/composer.phar?
Thanks!
I found the right way.
If I echo'ed PATH it told me that /home/site/wwwroot was included in the PATH, so all that's needed is to move the composer file into wwwroot doing something like mv composer.phar /home/site/wwwroot/composer.

AzCopy (devops pipeline)is not recognized as the name of a cmdlet, function, script file, or operable program

I have a PowerShell script that works all the time when I use from my local machine (I have azCopy installed):
AzCopy `
/Source:C:\myfolder `
/Dest:https://mystorageaccount.blob.core.windows.net/mystoragecontainer `
/DestKey:<storage-account-access-key> `
/Pattern:"myfile.txt"
Using azure pipeline (Microsoft Hosted agent) this script fails with
"AzCopy.exe : The term 'AzCopy.exe' is not recognized as the name of a cmdlet, function, script file, or operable program."
I have tried different agents but still the same error.
Which agent I must use to use azCopy?
Am I missing the obvious?
Is there another way of doing this always using powershell?
To copy files to Azure with AzCpoy you can use build-in task Azure File Copy, you not need use PowerShell:
In addition, you can install the Microsoft Azure Build and Release Tasks extension that give you another task "Azure Copy File Extended" with more options.
Agree with Shayki Abramczyk, the Azcopy task he provided can also be used to achieve copy file. This is another way, you can consider give it a try :-)
Back to this issue. According to error message, I think it's because the missing SDK in hosted agent.
Until now, Microsoft does not install Azure.Storage.AzCopy in every hosted agent. So, the agent you used may does not support this.
We provide seven different agents for user use, but only Hosted VS2017, Hosted Windows 2019 with VS2019 and Hosted Ubuntu 1604 has been installed the SDK which support Azcopy.exe.
So, you can try with these three agents to execute your azcopy command with powershell.
Edit:
Becaues the executable file (azcopy.exe)is in local. So, where is your AzCopy.exe located? For me, it's C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy.
So, in script, you need to execute cd command to change directory to the file where AzCopy.exe located first.
cd “C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy”
Note: DO NOT lost double quote here, or you will get x86 is not recognized. If file path located not same with mine, just change file path with yours.
And then, because of using Powershell, you may need to use powershell syntax. Here is the complete format example which modify it based on your script:
$source="C:\MyFolder"
$dest="https://mystorageaccount.blob.core.windows.net/mystoragecontainer"
$pattern = "myfile.txt"
$destkey = <key>
cd “C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy”
$azcopy = .\AzCopy.exe /Source:$source /Dest:$dest /DestKey: $destkey
/Pattern: $pattern
Please try with it.
For people like me, landing to this thread because they have this error by calling AZ copy in a PS Script, it's confirmed AZ Copy in not installed in Last (VM2019) version of Windows Hosted. But according to MS, binary is present in the Image, so you don't have to install it, but just to use the right path.
For more information about packages installed (or saved) on VM, you can check this Git Repo

How to auto-generate deploy.cmd in new Azure CLI?

I'm following this guide to create a web app with a custom deploy.cmd file. The article suggests that I can get a copy of the current deploy.cmd file (which I'll then modify) using the following command:
azure site deploymentscript --python
Unfortunately, when I install the Azure CLI using the MSI linked in the article, there is no azure binary on my path. I do have az -- is this a newer version of the same CLI? -- but I can't find an equivalent deployment script generation command for that executable.
I found a deploy.cmd file using Kudu (under D:\home\site\deployments\tools) but am not sure if that's the appropriate file to use. Can anyone suggest the right Azure CLI command for deployment script generation, or confirm that the deploy.cmd file I found is the right one to modify? Thanks in advance!
Based on my knowledge, there is not an equivalent to azure site deploymentscript in azure cli(2.0). So, you could not do deploy custom script with Azure CLI 2.0.
You had better know the difference between Azure cli 2.0(az) with Azure cli 1.0(azure).
Azure CLI 2.0: Our next-generation CLI written in Python, for use with
the Resource Manager deployment model.
Azure CLI 1.0: Our CLI written in Node.js, for use with both the
classic and Resource Managerdeployment models.
For your scenario, if you could install Azure ClI 1.0, you could refer to this link to install Azure CLI 1.0.
Instead of using the command line to generate a starter deployment script, there is an alternative approach that is often easier:
Deploy your repo without any deployment scripts.
Go to the site's Kudu Console.
From the Tools menu, choose 'Download deployment script'. You'll get a zip with a .deployment and deploy.cmd files.
Commit both files at the root of your repo
Tweak them as needed
More information please refer to this link.
You can use kuduscript to generate the deployment script.
npm install -g kuduscript
kuduscript --python
Here is the list of options
Options:
-h, --help output usage information
-V, --version output the version number
-r, --repositoryRoot [dir path] The root path for the repository (default: .)
--aspWAP <projectFilePath> Create a deployment script for .NET web application, specify the project file path
--aspNetCore <projectFilePath> Create a deployment script for ASP.NET Core web application, specify the project file path
--aspWebSite Create a deployment script for basic website
--go Create a deployment script for Go website
--node Create a deployment script for node.js website
--ruby Create a deployment script for ruby website
--php Create a deployment script for php website
--python Create a deployment script for python website
--functionApp [projectFilePath] Create a deployment script for function App, specify the project file path if using msbuild
--basic Create a deployment script for any other website
--dotNetConsole <projectFilePath> Create a deployment script for .NET console application, specify the project file path
-s, --solutionFile <file path> The solution file path (sln)
-p, --sitePath <directory path> The path to the site being deployed (default: same as repositoryRoot)
-t, --scriptType <batch|bash|posh> The script output type (default: batch)
-o, --outputPath <output path> The path to output generated script (default: same as repository root)
-y, --suppressPrompt Suppresses prompting to confirm you want to overwrite an existing destination file.
--no-dot-deployment Do not generate the .deployment file.
--no-solution Do not require a solution file path (only for --aspWAP otherwise ignored).

How to download a file from ubuntu virtual machine using Azure powershell script

I have created an Ubuntu VM on Azure and I want to download a file stored in one of the directories of this VM.
I want to do this using Powershell.
If you just want to grab a couple files, then you can use pscp. You can download pscp from here: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
Usage:
pscp.exe -r -pw 'password' 'local-path' adminuser#hostname.cloudapp.net:/path
If you want to do this more than once from multiple clients you can just serve the files with a web server, e.g. Apache. Then you can just use Invoke-WebRequest to download the files via HTTP.
Virtual machines in azure are completely locked down.
Do you just need to download the file once?
I am trying to understand your requirement of using PowerShell.
Here are a few options:
1. manually ftp the file from ubuntu to a FTP server and download it from there.
2. second option for you is to use Azure command line tools that run on ubuntu.
you should install Azure CLI
https://github.com/Azure/azure-xplat-cli
There are instructions for Ubuntu distributions.
One Azure CLI has been isntalled you can use the azure storage command line options to tranfer the file to an azure storage container.
After the files in an azure container you can use PowerShell to download it.
You can also use Azcopy tool to down the file from the container.
https://azure.microsoft.com/en-us/documentation/articles/storage-use-azcopy/
Let me know if this meets your needs.

Run PreSync/PostSync commands via WPP deploy.cmd

I'm trying to figure out how to run a pre/post command using the deploy.cmd generated by VS/MSBuild. I understand there are pre/postsync commands which can be set on the command line with msbuild but this is fixed within the web deploy package inside of the x.deploy.cmd.
How do I go about customizing the output of this file so that I can run the deploy command with specific parameters?
The intention is a non-developer will pick up the package zip file and import the application into IIS. We use IIS to host some windows services and so to be able to deploy we need to stop and uninstall the service before deployment and then install restart in the post deploy stage.
For certain servers we allow auto deployments from TFS and hook this pre/post command using the .targets file of the msbuild WPP pipeline. However, we want to this to be available to the manual deploy command files.
PreSync/PostSync are features of the msdeploy command line and are not supported by the package/manifest providers, or even the API. They are equivalent to running msdeploy a second time, so there's no way you'll be able to include their functionality while directly importing the package into IIS.
I'd recommend having a batch/powershell file on the server that the user runs after copying the package into the same directory.
The .cmd file that MSBuild generates is boilerplate script that you can simply change to call your pre/post powershell scripts. Just overwrite the one generated by the build with your custom one.

Resources