Start and Stop function apps in Powershell - azure-devops

I have stop and restart the Azure function app as part of my release process. I imported AzurePowerShell and using Inline Script.
enter code here
Stop-AzFunctionApp -Name fn-x-us-ed-HR02 -ResourceGroupName rg-t-HR02
getting below error.
The term 'Stop-AzFunctionApp' is not recognized as the name of a cmdlet, function, script file, or operable program.
I tried 'Stop-AzureRmWebApp' and getting same error.
I have 4 function apps and want to stop before deploying new and then restart.

You seem to be missing the latest Az.Functions module. Make sure you import v1.0.0 from the PowerShell Gallery: https://www.powershellgallery.com/packages/Az.Functions/1.0.0

Related

Getting error when I try using Sharepoint Online power shell commands

When I try to execute Powershell command, it gives the error:
Connect-SPOService : The term 'Connect-SPOService' 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.
Tried uninstalling and reiinstalling S P Online Management shell. None of the SPO commands are working.
On my system this came down to a conflicting .dll (different versions) that was found in both the SharePoint PowerShell module folder and the Global Assembly Cache.
I deleted the following file from the GAC:
C:\Program Files\WindowsPowerShell\tmp\Microsoft.SharePoint.Client.Publishing\v4.0_16.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.Client.Publishing.dll
After that everything was running smoothly. Full details on research leading to this is found here:
https://www.easy365manager.com/the-term-connect-sposervice-is-not-recognized/
Are you using the cmdlet in the SharePoint Online Management Shell or in the PowerShell? If you are using it in PowerShell, still you need to import the module with
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
Besides, ensure you are running the management shell under administrator privilege.
Here is a doc which may be helpful:https://learn.microsoft.com/en-us/powershell/sharepoint/sharepoint-online/connect-sharepoint-online?view=sharepoint-ps
On mac run the following command:
rm -rf Users/<username>/.local/share/powershell/Modules/Microsoft.Online.SharePoint.PowerShell/16.0.22810.12000/Microsoft.SharePoint.Client.Publishing.dll
PS: replace with username

Azure Functions Running AZ Commands

I have a Powershell Script that contains az commands which i am running from an Azure Function
I have The module specified in requirements.psd1 and host json managed dependency is enabled
In my script I have put in the following commands
Get-Module -Name Az -ListAvailable
Import-Module Az
Get Module comes back as 4.8.0 is installed
I then get a warning
[Warning] The Function app may be missing a module containing the 'az' command definition. If this command belongs to a module available on the PowerShell Gallery, add a reference to this module to requirements.psd1. Make sure this module is compatible with PowerShell 7. For more details, see https://aka.ms/functions-powershell-managed-dependency. If the module is installed but you are still getting this error, try to import the module explicitly by invoking Import-Module just before the command that produces the error: this will not fix the issue but will expose the root cause.
Followed by by actual command
az storage account keys list <blah>
[Error] ERROR: The term 'az' 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.
az cli is not available currently out the box in the functions
powershell environment. This is a feature ask and we are looking into
it.
Please refer to GitHub Issue#221 for this.
Using the corresponding Azure PowerShell Modules shall be the only way to go for now.
You can use Get-AzStorageAccountKey instead of az storage account keys

Can't submit Data Analytics job in PowerShell Portal

Why can't I run the Submit-AzureRmDataLakeAnalyticsJob cmdlet in a PowerShell runbook via the Aure web portal? I get the following error message:
Submit-AzureRmDataLakeAnalyticsJob : The term 'Submit-AzureRmDataLakeAnalyticsJob' 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.
I'm able to run this command with no errors in the PowerShell ISE.
Can this type of command not be run in a runbook or something? Maybe I'm just not understanding PowerShell
I seem to have solved the issue. I had to import some AzureRM.* modules via the Module Gallery on the portal.

Azure Powershell agent task pipeline

I'm just wondering whats the chain underlies Azure Powershell VSO agent task. I assume that is not simple powershell host because it is not working with some commandlets (for example Get-Module -ListAvailable) and fails with an error:
The term 'Get-ServiceEndpoint' 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.
A Connected Service with name 'xxxxx-xxxx-xxxxx-xxxx-xxxxxxxxxxx' could not be found. Ensure that
this Connected Service was successfully provisioned using services tab
in Admin UI.
VSTS build task are normal powershell scripts. However the 'Get-ServiceEndpoint' is a known issue: issue.
As far as I can see other cmdlets are working normally. I've been able to write several build tasks without any problems.

Alternate for esbimportutil.exe for PowerShell BizTalk

I am working on a PowerShell Deployment scripts for BizTalk. I want to import an itinerary in XML format using PowerShell. Commands available for this task is esbimportutil.exe. But this works only in Command Prompt and not in PowerShell.
The error shows is :
The term 'esbimportutil.exe' is not recognized as the name of a cmdlet, function, script file,
or operable program.
I run the PowerShell as an Administrator and even tried running the command from the source root location but still no use.
I got the solution. The problem was resolved by using a simple command:
Start-Process -FilePath "...\esbimportutil.exe" -ArgumentList $argument
The command "start-process" did the magic.