during the VSTS
deploy
I am calling the task Azure
PowerShell
(Preferred Azure PowerShell Version 5.1.1) where I am checking the Event Grid subscriptions and I am adding or updating:
$subscriptions = Get-AzureRmEventGridSubscription -ResourceGroupName $ResourceGroupName -TopicName $EventGridTopicName | WHERE EventSubscriptionName -eq $Subscription.Name
if (!$subscriptions)
{
Write-Host 'Add new subscription'
New-AzureRmEventGridSubscription -ResourceGroup $ResourceGroupName -TopicName $EventGridTopicName -Endpoint $Subscription.endpoint -EventSubscriptionName $Subscription.Name
Write-Host 'New subscription added'
}
else {
Write-Host 'Update endpoint'
Update-AzureRmEventGridSubscription -ResourceGroup $resourceGroupName -TopicName $eventGridTopicName -Endpoint $endpoint -EventSubscriptionName $eventGridSubscriptionName
Write-Host 'Subscription endpoint updated'
}
Running this code from local machine works fine. Running this as a part of VSTS deploy throws exception:
[error]The term 'Update-AzureRmEventGridSubscription' 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.
[EDIT]
[section]Starting: Azure PowerShell script: New-EventGridSubscription
Task : Azure PowerShell Description : Run a PowerShell script within an Azure environment Version : 2.0.11 Author : Microsoft Corporation
Help : More Information
[command]Import-Module -Name C:\Modules\AzureRm_5.1.1\AzureRM\5.1.1\AzureRM.psd1 -Global [command]Add-AzureRMAccount -ServicePrincipal -Tenant * -Credential System.Management.Automation.PSCredential -Environment AzureCloud [command] Select-AzureRMSubscription -SubscriptionId -TenantId [command]& 'D:\a\r1\a\Tools\scripts\New-EventGridSubscription.ps1' -ResourceGroupName -FunctionApps -EventGridTopicName *
[error]The term 'Update-AzureRmEventGridSubscription' 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. [section]Finishing: Azure PowerShell script: New-EventGridSubscription
Import-Module AzureRM
– gvee