0
votes

I have a Worker roles on Azure Cloud service (classic) and I want them to install Azure and AzureRM PowerShell modules on startup. I've added a startup task in my ServiceDefinition.csdef file:

<Startup>
  <Task commandLine="InstallAzureModules.cmd" executionContext="elevated" taskType="simple" />
</Startup>

InstallAzureModules.cmd file looks like this:

PowerShell.exe -ExecutionPolicy Unrestricted .\InstallAzureModules.ps1 >> "D:\InstallAzureModulesLogs.txt" 2>&1

And InstallAzureModules.ps1 looks like this:

Install-PackageProvider NuGet -Force

Install-Module Azure -AllowClobber -Force

Install-Module AzureRM -AllowClobber -Force

In result I have an error There is not enough space on the disk, however when I connect to any Worker instance using Remote Desktop and run InstallAzureModules.cmd manually all modules are installed without any errors.

Please help to have these modules installed.

Thanks.

1
When you login to the worker role how much space is on the disk? Also, why are you installing the RM module for a classic resource? - Micah_MSFT
@Micah_MSFT, when I login I see three drives C, D and E with 93 GB, 20 GB and 1.3 GB of free space. You're right: I don't need AzureRM module. - Mykola Mazurkevych
Thanks for the details. Not sure why you would get a disk space error unless you were forcing it to install on the E drive but that wouldn't make sense. You mentioned you can manually install them, once they are installed, is there a reason you are installing them on startup? You should only have to intsall the commands once. And, since its for classic commands there shouldnt be any updates to the modules so I don't see a need to install them every time on startup/ - Micah_MSFT
Azure module can be manually installed only on existing instances. When workers are scaled up, new instances will not have it installed. And that's why module installation should be part of the package and be processed for every instance when it's created. - Mykola Mazurkevych

1 Answers

0
votes

Finally after contacting Microsoft Support the issue was resolved!

According to Support Professional who was working with my request this error is due to a redirection of application temporary folder. I was recommended to go through this link for a possible fix, but it didn't work.

Also updates to my PS script were provided and what actually helped was setting TMP and TEMP environment variables to a folder on drive C. So here is my final script:

$env_TMP = $env:TMP
$env_TEMP = $env:TEMP
$env:TMP = "C:\_trashable\Modules"
$env:TEMP = "C:\_trashable\Modules"

Install-PackageProvider NuGet -Force

Install-Module Azure -AllowClobber -Force

$env:TMP = $env_TMP
$env:TEMP = $env_TEMP

ECHO "Finished"