Skip to content

Commit d870065

Browse files
authored
Merge pull request #5061 from kalyanaj/preview
Azure EventGrid: Adding cmdlets for updating topics and event subscriptions
2 parents 6865be3 + 66bab1c commit d870065

32 files changed

+5589
-103557
lines changed

src/ResourceManager/EventGrid/AzureRM.EventGrid.psd1

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Microsoft Corporation
55
#
6-
# Generated on: 11/3/2017
6+
# Generated on: 12/15/2017
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
# RootModule = ''
1313

1414
# Version number of this module.
15-
ModuleVersion = '0.2.0'
15+
ModuleVersion = '0.3.0'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()
@@ -76,6 +76,7 @@ CmdletsToExport = 'New-AzureRmEventGridTopic', 'Get-AzureRmEventGridTopic',
7676
'Set-AzureRmEventGridTopic', 'New-AzureRmEventGridTopicKey',
7777
'Get-AzureRmEventGridTopicKey', 'Remove-AzureRmEventGridTopic',
7878
'New-AzureRmEventGridSubscription',
79+
'Update-AzureRmEventGridSubscription',
7980
'Remove-AzureRmEventGridSubscription',
8081
'Get-AzureRmEventGridSubscription', 'Get-AzureRmEventGridTopicType'
8182

@@ -112,11 +113,18 @@ PrivateData = @{
112113
# IconUri = ''
113114

114115
# ReleaseNotes of this module
115-
ReleaseNotes = '* Add support for online help
116-
- Run Get-Help with the -Online parameter to open the online help in your default Internet browser'
116+
ReleaseNotes = '* Added the following new cmdlet:
117+
- Update-AzureRmEventGridSubscription
118+
- Update the properties of an Event Grid event subscription.'
119+
120+
# Prerelease string of this module
121+
# Prerelease = ''
122+
123+
# Flag to indicate whether the module requires explicit user acceptance for install/update
124+
# RequireLicenseAcceptance = $false
117125

118126
# External dependent modules of this module
119-
# ExternalModuleDependencies = ''
127+
# ExternalModuleDependencies = @()
120128

121129
} # End of PSData hashtable
122130

src/ResourceManager/EventGrid/ChangeLog.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!--
1+
<!--
22
Please leave this section at the top of the change log.
33
44
Changes for the current release should go under the section titled "Current Release", and should adhere to the following format:
@@ -19,6 +19,12 @@
1919
-->
2020
## Current Release
2121

22+
## Version 0.3.0
23+
* Added the following new cmdlet:
24+
- Update-AzureRmEventGridSubscription
25+
- Update the properties of an Event Grid event subscription.
26+
27+
2228
## Version 0.2.0
2329
* Add support for online help
2430
- Run Get-Help with the -Online parameter to open the online help in your default Internet browser
@@ -47,4 +53,4 @@
4753
- Remove-AzureRmEventGridSubscription
4854
- Removes an Azure Event Grid event subscription.
4955
- Get-AzureRmEventGridTopicType
50-
- Gets the details about the topic types supported by Azure Event Grid.
56+
- Gets the details about the topic types supported by Azure Event Grid.

src/ResourceManager/EventGrid/Commands.EventGrid.Test/Commands.EventGrid.Test.csproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@
5656
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
5757
<Private>True</Private>
5858
</Reference>
59-
<Reference Include="Microsoft.Azure.Management.EventGrid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
60-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.EventGrid.1.0.0-preview\lib\net452\Microsoft.Azure.Management.EventGrid.dll</HintPath>
61-
<Private>True</Private>
59+
<Reference Include="Microsoft.Azure.Management.EventGrid">
60+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.EventGrid.1.1.0-preview\lib\net452\Microsoft.Azure.Management.EventGrid.dll</HintPath>
6261
</Reference>
6362
<Reference Include="Microsoft.Azure.Management.EventHub">
6463
<HintPath>..\..\..\packages\Microsoft.Azure.Management.EventHub.2.0.0\lib\net452\Microsoft.Azure.Management.EventHub.dll</HintPath>
@@ -202,7 +201,7 @@
202201
<None Include="SessionRecords\Microsoft.Azure.Commands.EventGrid.Tests.ScenarioTests.TopicTests\EventGrid_TopicsNewKey.json">
203202
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
204203
</None>
205-
<None Include="SessionRecords\Microsoft.Azure.Commands.EventGrid.Tests.ScenarioTests.TopicTests\EventGrid_TopicsUpdate.json">
204+
<None Include="SessionRecords\Microsoft.Azure.Commands.EventGrid.Tests.ScenarioTests.TopicTests\EventGrid_TopicsSet.json">
206205
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
207206
</None>
208207
<None Include="SessionRecords\Microsoft.Azure.Commands.EventGrid.Tests.ScenarioTests.TopicTypeTests\EventGrid_TopicTypes.json">

src/ResourceManager/EventGrid/Commands.EventGrid.Test/ScenarioTests/EventSubscriptionTests.ps1

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ function EventSubscriptionTests_CustomTopic {
5151
$result = Get-AzureRmEventGridTopic -ResourceGroup $resourceGroupName -TopicName $topicName | Get-AzureRmEventGridSubscription -EventSubscriptionName $eventSubscriptionName -IncludeFullEndpointUrl
5252
Assert-True {$result.EventSubscriptionName -eq $eventSubscriptionName}
5353

54+
Write-Debug "Updating eventSubscription $eventSubscriptionName to topic $topicName in resource group $resourceGroupName"
55+
$result = Update-AzureRmEventGridSubscription -ResourceGroup $resourceGroupName -TopicName $topicName -Endpoint https://requestb.in/1kxxoui1 -EventSubscriptionName $eventSubscriptionName
56+
Assert-True {$result.ProvisioningState -eq "Succeeded"}
57+
$webHookDestination = $result.Destination -as [Microsoft.Azure.Management.EventGrid.Models.WebHookEventSubscriptionDestination]
58+
Assert-AreEqual $webHookDestination.EndpointBaseUrl "https://requestb.in/1kxxoui1"
59+
5460
Write-Debug "Listing all the event subscriptions created for $topicName in the resourceGroup $resourceGroup"
5561
$allCreatedSubscriptions = Get-AzureRmEventGridSubscription -ResourceGroup $resourceGroupName -TopicName $topicName -IncludeFullEndpointUrl
5662
Assert-True {$allCreatedSubscriptions.Count -eq 2 } "#1. Event Subscriptions created earlier are not found in the list"
@@ -100,6 +106,13 @@ function EventSubscriptionTests_CustomTopic2 {
100106
$result = Get-AzureRmEventGridSubscription -ResourceGroupName $resourceGroupName -TopicName $topicName -EventSubscriptionName $eventSubscriptionName -IncludeFullEndpointUrl
101107
Assert-True {$result.EventSubscriptionName -eq $eventSubscriptionName}
102108

109+
Write-Debug "Updating eventSubscription $eventSubscriptionName to topic $topicName in resource group $resourceGroupName"
110+
$updateResult = $result | Update-AzureRmEventGridSubscription -Endpoint https://requestb.in/1kxxoui1 -SubjectEndsWith "NewSuffix"
111+
Assert-True {$updateResult.ProvisioningState -eq "Succeeded"}
112+
$webHookDestination = $updateResult.Destination -as [Microsoft.Azure.Management.EventGrid.Models.WebHookEventSubscriptionDestination]
113+
Assert-AreEqual $webHookDestination.EndpointBaseUrl "https://requestb.in/1kxxoui1"
114+
Assert-True {$updateResult.Filter.SubjectEndsWith -eq "NewSuffix"}
115+
103116
Write-Debug " Deleting event subscription $eventSubscriptionName"
104117
Get-AzureRmEventGridTopic -ResourceGroupName $resourceGroupName -Name $topicName | Remove-AzureRmEventGridSubscription -EventSubscriptionName $eventSubscriptionName
105118

@@ -140,6 +153,16 @@ function EventSubscriptionTests_ResourceGroup {
140153
$result = Get-AzureRmEventGridSubscription -ResourceId "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName" -EventSubscriptionName $eventSubscriptionName -IncludeFullEndpointUrl
141154
Assert-True {$result.EventSubscriptionName -eq $eventSubscriptionName}
142155

156+
Write-Debug "Updating eventSubscription $eventSubscriptionName to resource group $resourceGroupName"
157+
$newLabels = "Marketing", "Sales"
158+
$updateResult = Update-AzureRmEventGridSubscription -ResourceGroup $resourceGroupName -EventSubscriptionName $eventSubscriptionName -SubjectEndsWith "NewSuffix" -Label $newLabels
159+
Assert-True {$updateResult.ProvisioningState -eq "Succeeded"}
160+
Assert-True {$updateResult.Filter.SubjectEndsWith -eq "NewSuffix"}
161+
$updatedLabels = $updateResult.Labels
162+
Assert-AreEqual 2 $updatedLabels.Count;
163+
Assert-AreEqual "Marketing" $updatedLabels[0];
164+
Assert-AreEqual "Sales" $updatedLabels[1];
165+
143166
Write-Debug "Listing all the event subscriptions created for resourceGroup $resourceGroup"
144167
$allCreatedSubscriptions = Get-AzureRmEventGridSubscription -ResourceId "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName"
145168

@@ -187,6 +210,13 @@ function EventSubscriptionTests_Subscription {
187210
$result = Get-AzureRmEventGridSubscription -ResourceId "/subscriptions/$subscriptionId" -EventSubscriptionName $eventSubscriptionName -IncludeFullEndpointUrl
188211
Assert-True {$result.EventSubscriptionName -eq $eventSubscriptionName}
189212

213+
Write-Debug "Updating eventSubscription $eventSubscriptionName to Azure subscription $subscriptionId"
214+
$updateResult = Update-AzureRmEventGridSubscription -ResourceId "/subscriptions/$subscriptionId" -EventSubscriptionName $eventSubscriptionName -SubjectEndsWith "NewSuffix" -Endpoint https://requestb.in/1kxxoui1
215+
Assert-True {$updateResult.ProvisioningState -eq "Succeeded"}
216+
Assert-True {$updateResult.Filter.SubjectEndsWith -eq "NewSuffix"}
217+
$webHookDestination = $updateResult.Destination -as [Microsoft.Azure.Management.EventGrid.Models.WebHookEventSubscriptionDestination]
218+
Assert-AreEqual $webHookDestination.EndpointBaseUrl "https://requestb.in/1kxxoui1"
219+
190220
Write-Debug "Listing all the event subscriptions created for subscription $subscriptionId"
191221
$allCreatedEventSubscriptions = Get-AzureRmEventGridSubscription -ResourceId "/subscriptions/$subscriptionId"
192222

@@ -235,6 +265,13 @@ function EventSubscriptionTests_Resource {
235265
$result = Get-AzureRmEventGridSubscription -ResourceId "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.EventHub/namespaces/$namespaceName" -EventSubscriptionName $eventSubscriptionName
236266
Assert-True {$result.EventSubscriptionName -eq $eventSubscriptionName}
237267

268+
Write-Debug "Updating eventSubscription $eventSubscriptionName to Azure resource $subscriptionId"
269+
$updateResult = Update-AzureRmEventGridSubscription -ResourceId "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.EventHub/namespaces/$namespaceName" -EventSubscriptionName $eventSubscriptionName -SubjectEndsWith "NewSuffix" -Endpoint https://requestb.in/1kxxoui1
270+
Assert-True {$updateResult.ProvisioningState -eq "Succeeded"}
271+
Assert-True {$updateResult.Filter.SubjectEndsWith -eq "NewSuffix"}
272+
$webHookDestination = $updateResult.Destination -as [Microsoft.Azure.Management.EventGrid.Models.WebHookEventSubscriptionDestination]
273+
Assert-AreEqual $webHookDestination.EndpointBaseUrl "https://requestb.in/1kxxoui1"
274+
238275
Write-Debug "Getting the created event subscription $eventSubscriptionName with full endpoint URL"
239276
$result = Get-AzureRmEventGridSubscription -ResourceId "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.EventHub/namespaces/$namespaceName" -EventSubscriptionName $eventSubscriptionName -IncludeFullEndpointUrl
240277
Assert-True {$result.EventSubscriptionName -eq $eventSubscriptionName}

src/ResourceManager/EventGrid/Commands.EventGrid.Test/ScenarioTests/TopicTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public void EventGrid_TopicsCreateGetAndDelete()
3737

3838
[Fact]
3939
[Trait(Category.AcceptanceType, Category.CheckIn)]
40-
public void EventGrid_TopicsUpdate()
40+
public void EventGrid_TopicsSet()
4141
{
42-
EventGridController.NewInstance.RunPsTest("TopicUpdateTests");
42+
EventGridController.NewInstance.RunPsTest("TopicSetTests");
4343
}
4444

4545
[Fact]

src/ResourceManager/EventGrid/Commands.EventGrid.Test/ScenarioTests/TopicTests.ps1

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ function TopicTests {
100100

101101
<#
102102
.SYNOPSIS
103-
Tests EventGrid Topic Update operations.
103+
Tests EventGrid Topic Set operations.
104104
#>
105-
function TopicUpdateTests {
105+
function TopicSetTests {
106106
# Setup
107107
$location = Get-LocationForEventGrid
108108
$topicName = Get-TopicName
@@ -119,23 +119,32 @@ function TopicUpdateTests {
119119
Assert-True {$result.ProvisioningState -eq "Succeeded"}
120120

121121
Write-Debug "Calling Set-AzureRmEventGridTopic on the created topic $topicName"
122-
$updatedTopic = Set-AzureRmEventGridTopic -ResourceGroup $resourceGroupName -Name $topicName -Tag @{ Dept = "IT2"; Environment = "Test2" }
123-
Assert-True {$updatedTopic.Count -eq 1}
124-
Assert-True {$updatedTopic.TopicName -eq $topicName} "Topic updated earlier is not found."
122+
$tags1 = @{test1 = "testval1"; test2 = "testval2" };
123+
$replacedTopic1 = Set-AzureRmEventGridTopic -ResourceGroup $resourceGroupName -Name $topicName -Tag $tags1
124+
Assert-True {$replacedTopic1.Count -eq 1}
125+
Assert-True {$replacedTopic1.TopicName -eq $topicName} "Topic updated earlier is not found."
125126

126127
Write-Debug "Calling Set-AzureRmEventGridTopic on the created topic $topicName"
127-
$updatedTopic = Set-AzureRmEventGridTopic -ResourceId "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.EventGrid/topics/$topicName" -Tag @{ Dept = "IT3"; Environment = "Test3" }
128-
Assert-True {$updatedTopic.Count -eq 1}
129-
Assert-True {$updatedTopic.TopicName -eq $topicName} "Topic updated earlier is not found."
128+
$tags2 = @{test1 = "testval1"; test2 = "testval2" };
129+
$replacedTopic2 = Set-AzureRmEventGridTopic -ResourceId "/subscriptions/$subscriptionId/resourceGroups/$resourceGroupName/providers/Microsoft.EventGrid/topics/$topicName" -Tag $tags2
130+
Assert-True {$replacedTopic2.Count -eq 1}
131+
Assert-True {$replacedTopic2.TopicName -eq $topicName} "Topic updated earlier is not found."
132+
$returned_tags2 = $replacedTopic2.Tags;
133+
Assert-AreEqual 2 $returned_tags2.Count;
134+
Assert-AreEqual $tags2["test1"] $returned_tags2["test1"];
135+
Assert-AreEqual $tags2["test2"] $returned_tags2["test2"];
130136

131137
Write-Debug "Calling Set-AzureRmEventGridTopic on the created topic $topicName"
132-
$updatedTopic = Get-AzureRmEventGridTopic -ResourceGroup $resourceGroupName -Name $topicName | Set-AzureRmEventGridTopic -Tag @{ Dept="IT4"; Environment="Test4" }
133-
Assert-True {$updatedTopic.Count -eq 1}
134-
Assert-True {$updatedTopic.TopicName -eq $topicName} "Topic updated earlier is not found."
135-
136-
# TODO: Verify updated tags after service side issue is fixed.
137-
138-
Write-Debug " Deleting topic: $topicName"
138+
$tags3 = @{test1 = "testval10"; test2 = "testval20" };
139+
$replacedTopic3 = Get-AzureRmEventGridTopic -ResourceGroup $resourceGroupName -Name $topicName | Set-AzureRmEventGridTopic -Tag $tags3
140+
Assert-True {$replacedTopic3.Count -eq 1}
141+
Assert-True {$replacedTopic3.TopicName -eq $topicName} "Topic updated earlier is not found."
142+
$returned_tags3 = $replacedTopic3.Tags;
143+
Assert-AreEqual 2 $returned_tags3.Count;
144+
Assert-AreEqual $tags3["test1"] $returned_tags3["test1"];
145+
Assert-AreEqual $tags3["test2"] $returned_tags3["test2"];
146+
147+
Write-Debug " Deleting topic: $topicName"
139148
Remove-AzureRmEventGridTopic -ResourceGroup $resourceGroupName -Name $topicName
140149

141150
Write-Debug " Deleting resourcegroup $resourceGroupName"

0 commit comments

Comments
 (0)