简体   繁体   中英

How to install a PowerShell module on an Azure web app without administrator permissions?

I am working on an internal tool that is meant to automatize app deployment on Azure. It is actually an MVC application where a user can upload zip-packages containing other apps and afterwards those get deployed on Azure (each of them to its own app service). Until now I was using "Microsoft.Azure.Management.Fluent" in C# which made things easy. Unfortunately it didn't allow me to make the kind of configurations I needed to make especially on Application gateway. Fortunately PowerShell does. I have already wrote the script that does everything I need. I can publish that script in my azure web app. The problem is that AzureRM module (which is a required module) is missing there. Also, I am not able to install it since I get an "You are not an administrator..." error (likely because I'm not an administrator on the actual Azure web app). Any ideas on how to install a PS module in an Azure web app?

Update: I know I can use Azure API in order to achieve my goal, but I would like to be able to run a normal PowerShell script (at least it's more readable).

Update 2 :) It seems like there is no way to install a PS module beside an web app since resources are shared and so on. I have decided to abandon using powershell with azureRM and execute api calls from my c# app.

If the version on the environment is not compatible with your requirements try to uninstall it first.

How to uninstall the AzureRM module to re-install a different version - https://docs.microsoft.com/en-us/powershell/azure/uninstall-azurerm-ps?view=azurermps-6.13.0

Install Azure RM Module with Power Shell - https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps?view=azurermps-6.13.0

You can try to install the module version you need to the current user environment (use Az module instead of AzureRM):

Install-Module -Name Az.Websites  -Scope CurrentUser

Tale a note that AzureRM is not recommended anymore:

Because Az PowerShell modules now have all the capabilities of AzureRM PowerShell modules and more, we'll retire AzureRM PowerShell modules on 29 February 2024. We do not support having both the AzureRM and Az modules installed for PowerShell 5.1 on Windows at the same time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM