Skip to content

Instantly share code, notes, and snippets.

@mirontoli
Last active April 29, 2022 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mirontoli/95cbde959582416248668e46d7326178 to your computer and use it in GitHub Desktop.
Save mirontoli/95cbde959582416248668e46d7326178 to your computer and use it in GitHub Desktop.
#trying out https://www.svenmalvik.com/azure-apim-with-eventhub/
# start azure cloud shell powershell
New-AzResourceGroup -Name "apim101-rg" -Location "West Europe"
New-AzApiManagement -ResourceGroupName "apim101-rg" -Name "svenmalvik-apim" -Sku "Consumption" -Capacity 0 -Location "West Europe" -Organization "chuvash.eu" -AdminEmail "doesnotexist@chuvash.eu"
# The context tells us what instance of APIM we're working with
$apimCtx = New-AzApiManagementContext -ResourceGroupName "apim101-rg" -ServiceName "svenmalvik-apim"
# Add Conference API to the APIM instance
Import-AzApiManagementApi -Context $apimCtx -SpecificationFormat "Swagger" -SpecificationUrl "https://conferenceapi.azurewebsites.net?format=json" -Path "conf" -ApiId "confapi"
# Create Event Hub namespace
New-AzEventHubNamespace -ResourceGroupName "apim101-rg" -Name "svenmalvik-eh-ns" -Location "West Europe" -SkuName "Basic" -SkuCapacity 1
# Create Event Hub # Did not work, created manually
New-AzEventHub -ResourceGroupName "apim101-rg" -NamespaceName "svenmalvik-eh-ns" -Name "svenmalvik-eh"
# Add Access to Event Hubs namespace
New-AzEventHubAuthorizationRule -ResourceGroupName "apim101-rg" -NamespaceName "svenmalvik-eh-ns" -AuthorizationRuleName "svenmalvik-eh-auth-rule" -Rights @("Listen", "Send")
# Get the connectionString to the Event Hubs namespace
$ehConnection = (Get-AzEventHubKey -ResourceGroupName "apim101-rg" -NamespaceName "svenmalvik-eh-ns" -AuthorizationRuleName "svenmalvik-eh-auth-rule").PrimaryConnectionString
# Create Azure API Management Event Hub logger
New-AzApiManagementLogger -Context $apimCtx -LoggerId "svenmalvik-logger" -Name "svenmalvik-logger" -ConnectionString "$ehConnection;EntityPath=svenmalvik-eh"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment