Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 674
coceban.vlad Avatar asked Dec 05 '18 18:12

coceban.vlad


People also ask

How do I manually install PowerShell modules?

To install PowerShell modules manually, you first need to determine your current PowerShell module directory path, download your new module to that path, and invoke the import-module command to let windows know it's there.

How do I manually install a PowerShell module offline?

Installing powershell modules is simple, right? Open a powershell window and use the Find-Module cmdlet or if you know the name of the module go straight to Install-Module. This will connect to the powershell gallery and download and install the module for you.


1 Answers

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.

like image 165
Hardoman Avatar answered Sep 19 '22 01:09

Hardoman