Open YingChen1996 opened 3 months ago
(base) PS C:\Users\cy> powershell -ExecutionPolicy Bypass -File .ps1 -SubscriptionIds ''
New-AzPolicyDefinition : A parameter cannot be found that matches parameter name 'Depth'. At D:\repro\microsoft\promptflow\examples\tutorials\flow-deploy\azure-app-service\SharedKeyAccessDisabledPolicy.ps1:43 char:5
+ CategoryInfo : InvalidArgument: (:) [New-AzPolicyDefinition], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,New-AzPolicyDefinition
param ( [string[]]$SubscriptionIds ) Connect-AzAccount foreach ($SubId in $SubscriptionIds) { Set-AzContext -SubscriptionId $SubId $policy = '{ "if": { "allOf": [{ "field": "type", "equals": "Microsoft.Storage/storageAccounts" }, { "not": { "field": "Microsoft.Storage/storageAccounts/allowSharedKeyAccess", "equals": "false" } } ] }, "then": { "effect": "modify", "details": { "roleDefinitionIds": [ "/providers/Microsoft.Authorization/roleDefinitions/17d1049b-9a84-46fb-8f53-869881c3d3ab" ], "conflictEffect": "deny", "operations": [{ "operation": "addOrReplace", "field": "Microsoft.Storage/storageAccounts/allowSharedKeyAccess", "value": false } ] } } }' $parameters = '{}' $policyDefinition = New-AzPolicyDefinition -Name 'SharedKeyAccessDisabled' -Description 'Ensure Storage with shared key access disabled.' -Policy $policy -Parameter $parameters -Mode All $policyAssignment = New-AzPolicyAssignment -Name "SharedKeyAccessDisabled" -Scope "/subscriptions/$SubId" -PolicyDefinition $policyDefinition Write-Host "Policy assigned to subscription: $SubId" }
Name Value ---- ----- PSVersion 7.4.3 PSEdition Core GitCommitId 7.4.3 OS Microsoft Windows 10.0.22631 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
ModuleType Version PreRelease Name PSEdition ExportedCommands ---------- ------- ---------- ---- --------- ---------------- Script 11.2.0 Az Core,Desk Script 8.3.0 Az Core,Desk Script 2.15.0 Az.Accounts Core,Desk {Disable-AzDataCollection, Disable-AzContextAutosave, Enable-AzDataCollection… Script 2.10.1 Az.Accounts Core,Desk {Disable-AzDataCollection, Disable-AzContextAutosave, Enable-AzDataCollection… Script 2.0.0 Az.Advisor Core,Desk {Disable-AzAdvisorRecommendation, Enable-AzAdvisorRecommendation, Get-AzAdvis… Script 1.1.2 Az.Advisor Core,Desk {Get-AzAdvisorRecommendation, Enable-AzAdvisorRecommendation, Disable-AzAdvis… Script 6.0.0 Az.Aks Core,Desk {Get-AzAksCluster, New-AzAksCluster, Remove-AzAksCluster, Import-AzAksCredent… Script 4.3.0 Az.Aks Core,Desk {Get-AzAksCluster, New-AzAksCluster, Remove-AzAksCluster, Import-AzAksCredent… Script 1.1.4 Az.AnalysisServices Core,Desk {Resume-AzAnalysisServicesServer, Suspend-AzAnalysisServicesServer, Get-AzAna… Script 4.0.2 Az.ApiManagement Core,Desk {Add-AzApiManagementApiToGateway, Add-AzApiManagementApiToProduct, Add-AzApiM… Script 3.0.1 Az.ApiManagement Core,Desk {Add-AzApiManagementApiToGateway, Add-AzApiManagementApiToProduct, Add-AzApiM… Script 1.0.0 Az.App Core,Desk {Disable-AzContainerAppRevision, Enable-AzContainerAppRevision, Get-AzContain…
No response
Adding @mentat9
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @aperezcloud, @kenieva.
This is fixed in the recent 7.2.0 Az.Resources release.
Description
(base) PS C:\Users\cy> powershell -ExecutionPolicy Bypass -File .ps1 -SubscriptionIds ''
New-AzPolicyDefinition : A parameter cannot be found that matches parameter name 'Depth'. At D:\repro\microsoft\promptflow\examples\tutorials\flow-deploy\azure-app-service\SharedKeyAccessDisabledPolicy.ps1:43 char:5
Issue script & Debug output
Environment data
Module versions
Error output
No response