Azure Powershell agent task pipeline - powershell

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.

Related

Why is System.AccessToken is not recognized as the name of a cmdlet in a Release in Azure DevOps?

I am building a task in my Release in Azure DevOps. In this task, I have a Powershell script I am running that needs to call some of Azure's Web APIs and so forth so I have a parameter to pass in the AccessToken. But I am getting the following error:
System.AccessToken : The term 'System.AccessToken' 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.
Here is what my parameter that I am passing in looks like.
-AccessToken "$(System.AccessToken)"
Why is this happening? Is there a work around?
You need to enable access to OAuth token in your agent job
See this https://learn.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=classic#access-to-oauth-token

Azure Powershell - Add-AzureVirtualIP cmdlet not found

I need to add another VIP for my Azure cloud service using Powershell for Azure, since there is no way to do it via the web console. In the past I was able to do it by using the Add-AzureVirtualIP command.
However, that command seems to no longer be found since MS switched everything to Azure Resource Manager mode. How can I use this command again, or is there another way to add a VIP to my cloud service?
Add-AzureVirtualIP : The term 'Add-AzureVirtualIP' 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
According to your error code, it seems the Azure PowerShell is not loaded correctly. we can install Azure PowerShell with this command:
Install-Module -Name Azure
More information about Azure PowerShell, please refer to the link.

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.

Manage Azure Redis Cache with Azure PowerShell

When I try to run below command to just start with Azure Redis cache I am getting below error message. Am I missing something? I am using Windows PowerShell, Version 3.0.
PS C:> New-AzureRedisCache
New-AzureRedisCache : The term 'New-AzureRedisCache' 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.
You don't have all the prerequisites complete (no Azure PowerShell commands loaded). Follow the instructions at Manage Azure Redis Cache with Azure PowerShell.

Powershell Webjob fails to run

I have created a Powershell Webjob for use in the Azure Logic App. The code is trying to generate a signed URI so the end user can download the file when its available. To do that I created a simple Powershell Webjob.
New-AzureStorageContext : The term 'New-AzureStorageContext' 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.
CommandNotFoundException New-AzureStorageBlobSASToken : The term 'New-AzureStorageBlobSASToken' 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 know these are part of the Azure Powershell. But is there an alternative for them to run? Or would I need to resolve to a separate console application?
After a lot of google searching, I found that Azure Powershell jobs do not support Azure commands. They have a plan to allow for that, but currently you cannot run Azure PowerShell Jobs on WebApps Webjob.