Skip to content

Instantly share code, notes, and snippets.

@gsscoder
Created April 3, 2020 06:24
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 gsscoder/7bde38b8a2fbbd80add148d1058f2ca9 to your computer and use it in GitHub Desktop.
Save gsscoder/7bde38b8a2fbbd80add148d1058f2ca9 to your computer and use it in GitHub Desktop.
Attempt to create APIM with New-AzResource
# This code actually doesn't work.
$secret = 'B=EBh3glTf523Xj@uLGO]o@kSteLoC@O'
$group = 'INTRANETAI-Europe-DEV'
$service = 'intranetai-europe-test-dev'
$context = New-AzApiManagementContext -ResourceGroupName $group -ServiceName $service
$versionSet = New-AzApiManagementApiVersionSet -Context $context -Name 'news' `
-Scheme Header -HeaderName 'x-api-version' `
-Description 'version by x-api-version'
$id = $versionSet.Id -replace 'apiVersionSets', 'api-version-sets'
$props = @{
"name" = 'news/ver1'
"serviceUrl" = $null
"path" = 'SampleFunc'
"protocols" = @("https")
"apiVersionSetId" = $id
"apiVersion" = 'v1'
}
New-AzResource -PropertyObject $props -ResourceGroupName $group `
-ResourceType Microsoft.ApiManagement/service/apis `
-ResourceName "$service/news/ver1" `
-ApiVersion 2018-01-01 -Force
$props = @{
"name" = 'news/ver2'
"serviceUrl" = $null
"path" = 'SampleFunc'
"protocols" = @("https")
"apiVersionSetId" = $id
"apiVersion" = 'v2'
}
New-AzResource -PropertyObject $props -ResourceGroupName $group `
-ResourceType Microsoft.ApiManagement/service/apis `
-ResourceName "$service/news/ver2" `
-ApiVersion 2018-01-01 -Force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment