scautomation / Azure-Inventory-Workbook

The Ultimate Azure Inventory Dashboard
142 stars 93 forks source link

A parameter cannot be found that matches parameter name 'workbookSerializedData' #7

Closed winticloud closed 3 years ago

winticloud commented 3 years ago

When running the PS code, the following error occurs New-AzResourceGroupDeployment : A parameter cannot be found that matches parameter name 'workbookSerializedData'. At line:6 char:3 -workbookSerializedData ($workbookSerializedData | ConvertTo-Json - ... CategoryInfo : InvalidArgument: (:) [New-AzResourceGroupDeployment], ParameterBindingException FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet In the armTemplate/template.json, the parameter named workbookSerializedData seems to be missing

scautomation commented 3 years ago

take out that parameter and it works. I'll update the powershell, not sure what @JamesDLD did cause i got the same error. ill take that out of the example in the repo

JamesDLD commented 3 years ago

These are the missing lines. When doing a pull request it doesn't see it :

image
JamesDLD commented 3 years ago

Hi @scautomation , another method, much more elegant actually is to get the workbookSerializedData from the json itself like :

## Variable
$AzureRmSubscriptionName = "my-subsctiption-name"
$RgName = "my-workbook-rg-name"
$workbookDisplayName = "Network Debug"
$workbookSourceId = "Azure Monitor"
$workbookType = "workbook"
$templateUri = "https://raw.githubusercontent.com/JamesDLD/AzureRm-Template/master/Create-AzWorkbookNetwork/template.json"
$workbookSerializedData = Invoke-RestMethod -Uri "https://raw.githubusercontent.com/JamesDLD/AzureRm-Template/master/Create-AzWorkbookNetwork/galleryTemplate.json"

## Connectivity
# Login first with Connect-AzAccount if not using Cloud Shell
$AzureRmContext = Get-AzSubscription -SubscriptionName $AzureRmSubscriptionName | Set-AzContext -ErrorAction Stop
Select-AzSubscription -Name $AzureRmSubscriptionName -Context $AzureRmContext -Force -ErrorAction Stop

## Action
Write-Host "Deploying : $workbookType-$workbookDisplayName in the resource group : $RgName" -ForegroundColor Cyan
New-AzResourceGroupDeployment -Name $(("$workbookType-$workbookDisplayName").replace(' ', '')) -ResourceGroupName $RgName `
  -TemplateUri $TemplateUri `
  -workbookDisplayName $workbookDisplayName `
  -workbookType $workbookType `
  -workbookSourceId $workbookSourceId `
  -workbookSerializedData ($workbookSerializedData | ConvertTo-Json -Depth 20) `
  -Confirm -ErrorAction Stop

Source : NSG Traffic Analytics with an Azure Monitor Workbook