Error while deploying locally - Azure IOT remote monitoring suite - powershell

Team,
We are trying out this IOT remote monitoring suite from github. We are trying to first deploy that locally instead of Azure and hence we have followed the document mentioned here https://github.com/Azure/azure-iot-remote-monitoring/blob/master/Docs/local-deployment.md
Also, we have followed the pre-requisites over here https://github.com/Azure/azure-iot-remote-monitoring/blob/master/Docs/dev-setup.md
We then come over to my developer command prompt (running as admin) but we end up having error:
Get-AzureEnvironment : The 'Get-AzureEnvironment' command was found in
the module 'Azure', but the module could not be loaded. For more
information, r 'Import-Module Azure'. At
C:\Users\swagh\Downloads\azure-iot-remote-monitoring-master\azure-iot-re
-monitoring-master\Common\Deployment\PrepareIoTSample.ps1:14 char:14
+ if ((Get-AzureEnvironment AzureCloud) -eq $null)
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-AzureEnvironment:String) , CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule
Get-AzureRMEnvironment : The 'Get-AzureRMEnvironment' command was
found in module 'AzureRM', but the module could not be loaded. For
more information, run 'Import-Module AzureRM'.
The modules has been imported successfully but not sure why it fails while building the soln locally. Tried setting the execution policy to bypass, unrestricted. Also scoped to the current user but its not helping.
We have run out of ideas. Can anyone help please?

According to your error message, it seems you have not install Azure PowerShell correctly.
We can install download Azure PowerShell here. After download azure-powershell.4.2.0.msi completed, run as administrator.
We can find latest version of Azure powershell here.
We can run this command in Azure PowerShell version 4.2.0:

Azure error
The screenshot for the above error.

Related

Cannot Uninstall IoT Edge on Windows Server

I need to swap an IoT Edge device on Windows from one IoT Hub to another. I understand that current logic forces me to Uninstall IoT-Edge and install it again.
The problem is I get the following error trying to run this script:
{Invoke-WebRequest -useb aka.ms/iotedge-win} | Invoke-Expression; `
Uninstall-IoTEdge
I get this in return:
Invoke-Native : The term 'cmd' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1748 char:28
+ ... ersString = Invoke-Native "$dockerExe ps --all --format ""{{.ID}}""" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (cmd:String) [Invoke-Native], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,Invoke-Native
The Powershell is elevated as Admin. Am my missing some PATH variables? Any Ideas?
would you please run below commands in PowerShell window and share the results?
Get-Command "docker.exe"
Write-Host $env:ProgramFiles\iotedge-moby
check if the path exists or not.
do you know which version of iotedge service you installed? if the service is running, you can run "iotedge version" to find it out.
Thanks for the suggestion, but did manage to find workaround by removing docker with the help of this script:
https://success.docker.com/article/how-to-completely-remove-docker-in-windows-10
As fas as IOT Edge version it is 1.0.7 as 1.0.8. does not work in transparent gateway mode with Node-Red MQTT node (MS advised to wait for 1.0.9 where this bug will be fixed).

PowerShell script and libeay32.dll with Azure Function App

I'm trying to use a PowerShell script that works on my machine in an Azure Function App.
In short, the script uses a Service Principal profile json to login to Azure and then does some magic to renew my Let's Encrypt SSL certificate.
The script itself is in a file called Register-LetsEncryptCertificateSP.ps1 and I can run it successfully in local PowerShell ISE by calling it like this:
PS C:\tmp\test> .\Register-LetsEncryptCertificateSP.ps1 -Domain dev.mysite.com -RegistrationEmail my#email.com -ResourceGroup my-resourcegroup-name -WebApp my-webapp-name -ServicePrincipalProfilePath "c:\tmp\letsencryptSP.json".
I added Service Principal support to Lee Holmes's script which prompts for Azure account credentials by default: https://www.powershellgallery.com/packages/Register-LetsEncryptCertificate/1.0/DisplayScript
I'm trying to put this script inside a TimerTriggerPowerShell Function App. The script requires following modules: #requires -Modules AcmeSharp, Azure, AzureRM.Websites
Azure and AzureRM.Websites are available by default and I have uploaded ACMESharp to modules/ -directory` but when I run the script in Azure I get the following log:
2017-04-03T09:46:23.499 Function started (Id=015f9081-8bc2-4801-b392-76e53da027f7)
2017-04-03T09:46:23.983 Loaded modules:
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp.psd1
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp-AWS/ACMESharp-AWS.psd1
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp-IIS/ACMESharp-IIS.psd1
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp.PKI.Providers.OpenSslLib32.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp.PKI.Providers.OpenSslLib64.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp.POSH-test.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp.POSH.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp.Providers.AWS.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp.Providers.IIS.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp.Vault.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/AWSSDK.Core.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/AWSSDK.Route53.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/AWSSDK.S3.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ManagedOpenSsl.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/Microsoft.Web.Administration.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/Newtonsoft.Json.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/x86/libeay32.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/x86/ssleay32.dll
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp-AWS/ACMESharp-AWS.psm1
/TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp-IIS/ACMESharp-IIS.psm1
2017-04-03T09:46:24.186 Import-Module : The specified module 'AWSPowerShell' was not loaded because no valid module file was found in any module directory.
at <ScriptBlock>, /TimerTriggerPowerShell1/modules/ACMESharp/0.8.1/ACMESharp-AWS/ACMESharp-AWS.psm1: line 17
+ Import-Module
+ _____________
+ CategoryInfo : ResourceUnavailable: (AWSPowerShell:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
2017-04-03T09:46:24.280 Function completed (Failure, Id=015f9081-8bc2-4801-b392-76e53da027f7)
2017-04-03T09:46:24.343 Exception while executing function: Functions.TimerTriggerPowerShell1. System.Management.Automation: Could not load file or assembly 'file:///D:\home\site\wwwroot\TimerTriggerPowerShell1\modules\ACMESharp\0.8.1\x86\libeay32.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
The app service is running on 32bit. Any ideas how to solve this error?

How do I correctly install the PowerShell MSOnline module in Windows 8.1 Enterprise?

I'm trying to write some scripts for Azure Active Directory / Office online, and I'm completely unable to install the MSOnline powershell module. I've installed the Office Sign In Assistant version 7.2 (64-bit for my 64-bit machine). When I try to run the MSI installer for the PowerShell module, it says it can't find the sign in assistant. When I install the powershell module through PowerShellGet, and then run the commands, it fails with:
Connect-MsolService : The Microsoft Online Services Module is not configured properly. Please uninstall and then reinstall the module.
At line:1 char:1
+ Connect-MsolService
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Connect-MsolService], InvalidConfigurationException
+ FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.InvalidConfigurationException,Microsoft.Online.Administration.Automation.ConnectMsolService
Connect-MsolService : Object reference not set to an instance of an object.
At line:1 char:1
+ Connect-MsolService
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [Connect-MsolService], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.Online.Administration.Automation.ConnectMsolService
Is there any way to get this installed ? I've even changed the language of my system to US-English and installed the correct language pack (because I've run into issues before with things not installing correctly if the system language is not US English)
Found at least a partial answer here that worked (at least got the module working again for one of my accounts, the other one still fails and remains a mystery):
MSOnline can't be imported on PowerShell (Connect-MsolService error)
In my case, some registry keys were missing (I don't know why) and reinstalling didn't help. I imported the registry keys with one path adaption from another system and now it works. I used the following registry keys (just copy to a file powershell.reg, change InstallPath if necessary, and import):
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSOnlinePowerShell]
"Version"="1.0.0"
"InstallPath"="c:\\Program Files\\WindowsPowerShell\\Modules\\MSOnline\\1.0\\"
"InstallLanguage"="en-us"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSOnlinePowerShell\Path]
"WebServiceUrl"="https://provisioningapi.microsoftonline.com/provisioningwebservice.svc"
"FederationProviderIdentifier"="microsoftonline.com"
Follow the steps to install the Azure AD Module here

Azure App Service Scaling powershell

I have app service in my environment named "Standard" . Currently the app service is configured in standard tier small 1 instance.
Using powershell I am trying to scale the app service which will in turn scale the web apps inside this app service.
I want to change size to Medium and instances to 2.
Here is my snippet.
Login-AzureRmAccount
Set-AzureRMAppServicePlan -Name Standard -ResourceGroupName
MyWebAppRG - NumberofWorkers 2 -WorkerSize Medium
When I run this command I am getting following error
Set-AzureRMAppServicePlan : Could not load file or assembly 'Microsoft.Rest.ClientRuntime.Azure.Authentication, Version=0.11.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
At line:11 char:1
+ Set-AzureRMAppServicePlan -Name Standard -ResourceGroupName MyWebAppRG -Numbero ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-AzureRMAppServicePlan], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.Azure.Commands.WebApps.Cmdlets.AppServicePlans.SetAzureAppSe
rvicePlanCmdlet
I am not sure, what's wrong here? and what exactly this error means.
For the information, I am able to run other powershell commands just fine,example set-AzureRMResource and others. so isn't an environment issue.
Any help appreciated..
Thanks
What version of the Azure Powershell are you using? This was a known issue in Azure Powershell 1.0.0. If you are using that version, use the version below instead. Do post back if you still see issues.
https://github.com/Azure/azure-powershell/releases/tag/v1.0.1-November2015

Windows Azure Powershell command Get-AzureWebsite results in error String was not recognized as a valid Boolean

I'm trying to manage some of my Azure Services via Powershell, using http://windowsazurewebsitescheatsheet.info/#powershell as a starting point. I was able to download and import my subscription settings just fine (Import-AzurePublishSettingsFile and Select-AzureSubscription)
After choosing my subscription, I'm attempting to run the Get-AzureWebsite command to view all of my websites, and continue onward from there. When I run that command, however, I get the following:
Import-AzurePublishSettingsFile "C:\AzureCredentials.publishsettings"
Select-AzureSubscription "My Azure Subscription"
Get-AzureWebsite
Get-AzureWebsite : String was not recognized as a valid Boolean.
At line:1 char:1
+ Get-AzureWebsite
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureWebsite], FormatException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Websites.GetAzureWebsiteCommand
Anyone have similar issues? I get this error if I run the command as stated above, or if I specify the name of my website. TIA for any help!
This might be related to a known issue enumerating a sites with SSL bindings
There was new release of Windows Azure Powershell released on 02/12. Please try with the new version.
Please run the command again with -Debug turned on, this will display request and response messages and make it easier to pinpoint the issue.