BenchPress.Azure.psm1

# file Modules/BenchPress.Azure/Classes/AuthenticationData.psm1
class AuthenticationData {
  [string]$SubscriptionId

  AuthenticationData([string]$SubscriptionId) {
    $this.SubscriptionId = $SubscriptionId
  }
}
# file Modules/BenchPress.Azure/Classes/AuthenticationResult.psm1

class AuthenticationResult {
  [boolean]$Success
  [AuthenticationData]$AuthenticationData
}
# file Modules/BenchPress.Azure/Classes/ConfirmResult.psm1

class ConfirmResult {
  [boolean]$Success = $false
  [System.Object]$ResourceDetails
  [AuthenticationData]$AuthenticationData

  ConfirmResult([System.Object]$Resource, [AuthenticationData]$AuthenticationData) {
    $this.Success = -not $null -eq $Resource
    $this.ResourceDetails = $Resource
    $this.AuthenticationData = $AuthenticationData
  }

  ConfirmResult([AuthenticationData]$AuthenticationData) {
    $this.AuthenticationData = $AuthenticationData
  }
}
# file Modules/BenchPress.Azure/Classes/ResourceType.psm1
enum ResourceType{
  ActionGroup
  AksCluster
  AksNodePool
  ApiManagement
  ApiManagementApi
  ApiManagementDiagnostic
  ApiManagementLogger
  ApiManagementPolicy
  AppInsights
  AppServicePlan
  ContainerApp
  ContainerAppManagedEnv
  CosmosDBAccount
  CosmosDBGremlinDatabase
  CosmosDBMongoDBDatabase
  CosmosDBSqlDatabase
  CosmosDBSqlRoleAssignment
  CosmosDBSqlRoleDefinition
  ContainerRegistry
  DataFactory
  DataFactoryLinkedService
  DiagnosticSetting
  EventHub
  EventHubConsumerGroup
  EventHubNamespace
  KeyVault
  KeyVaultCertificate
  KeyVaultKey
  KeyVaultSecret
  OperationalInsightsWorkspace
  PortalDashboard
  PostgreSqlFlexibleServer
  ResourceGroup
  RoleAssignment
  SqlDatabase
  SqlServer
  StorageAccount
  StorageContainer
  StreamAnalyticsCluster
  StreamAnalyticsFunction
  StreamAnalyticsInput
  StreamAnalyticsJob
  StreamAnalyticsOutput
  StreamAnalyticsTransformation
  SynapseSparkPool
  SynapseSqlPool
  SynapseWorkspace
  VirtualMachine
  WebApp
  WebAppStaticSite
}
# file Modules/BenchPress.Azure/Public/Confirm-ActionGroup.ps1

function Confirm-ActionGroup {
  <#
    .SYNOPSIS
      Confirms that an Action Group exists.

    .DESCRIPTION
      The Confirm-AzBPActionGroup cmdlet gets an Action Group using the specified Action Group and Resource Group names.

    .PARAMETER ActionGroupName
      The name of the Azure Action Group.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPActionGroup -ActionGroupName "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ActionGroupName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzActionGroup -ResourceGroupName $ResourceGroupName -Name $ActionGroupName

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-AksCluster.ps1

function Confirm-AksCluster {
  <#
    .SYNOPSIS
      Confirms that an AKS Cluster exists.

    .DESCRIPTION
      The Confirm-AzBPAksCluster cmdlet gets an AKS Cluster using the specified AKS Cluster and Resource Group names.

    .PARAMETER AKSName
      The name of the AKS Cluster.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPAksCluster -AKSName "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$AksName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzAksCluster -ResourceGroupName $ResourceGroupName -Name $AksName

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-AksNodePool.ps1

function Confirm-AksNodePool {
  <#
    .SYNOPSIS
      Confirms that an AKS Node Pool exists.

    .DESCRIPTION
      The Confirm-AzBPAksNodePool cmdlet gets an AKS Node Pool using the specified AKS Node Pool and Resource Group names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER ClusterName
      The name of the Managed Cluster.

    .PARAMETER Name
      The name of the Node Pool.

    .EXAMPLE
      Confirm-AzBPAksNodePool -ResourceGroupName "rgbenchpresstest" -ClusterName "clustertest" -Name "benchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$ClusterName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzAksNodePool -ResourceGroupName $ResourceGroupName -ClusterName $ClusterName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-ApiManagement.ps1

function Confirm-ApiManagement {
  <#
    .SYNOPSIS
      Confirms that an API Management Service exists.

    .DESCRIPTION
      The Confirm-AzBPApiManagement cmdlet gets an API Management Service using the specified API Management Service
      and Resource Group names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER Name
      The name of the API Management Service.

    .EXAMPLE
      Confirm-AzBPApiManagement -ResourceGroupName "rgbenchpresstest" -Name "benchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzApiManagement -ResourceGroupName $ResourceGroupName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-ApiManagementApi.ps1

function Confirm-ApiManagementApi {
  <#
    .SYNOPSIS
      Confirms that an API Management API exists.

    .DESCRIPTION
      The Confirm-AzBPApiManagementApi cmdlet gets an API Management API using the specified API, API Management
      Service, and Resource Group names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER ServiceName
      The name of the API Management Service.

    .PARAMETER Name
      The name of the API.

    .EXAMPLE
      Confirm-AzBPApiManagementApi -ResourceGroupName "rgbenchpresstest" -ServiceName "servicetest" -Name "benchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$ServiceName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = New-AzApiManagementContext -ResourceGroupName $ResourceGroupName -ServiceName $ServiceName
    | Get-AzApiManagementApi -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-ApiManagementDiagnostic.ps1

function Confirm-ApiManagementDiagnostic {
  <#
    .SYNOPSIS
      Confirms that an API Management Diagnostic exists.

    .DESCRIPTION
      The Confirm-AzBPApiManagementDiagnostic cmdlet gets an API Management Diagnostic using the specified API
      Diagnostic, API, API Management Service, and Resource Group names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER ServiceName
      The name of the API Management Service.

    .PARAMETER Name
      The ID of the Diagnostic. This will return product-scope policy. This parameter is required.

    .EXAMPLE
      Confirm-AzBPApiManagementDiagnostic -ResourceGroupName "rgbenchpresstest" -ServiceName "servicetest" `
        -Name "benchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$ServiceName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = New-AzApiManagementContext -ResourceGroupName $ResourceGroupName -ServiceName $ServiceName
    | Get-AzApiManagementDiagnostic -DiagnosticId $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-ApiManagementLogger.ps1

function Confirm-ApiManagementLogger {
  <#
    .SYNOPSIS
      Confirms that an API Management Logger exists.

    .DESCRIPTION
      The Confirm-AzBPApiManagementLogger cmdlet gets an API Management Logger using the specified Logger, API
      Management Service, and Resource Group names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER ServiceName
      The name of the API Management Service.

    .PARAMETER Name
      The ID of the Logger.

    .EXAMPLE
      Confirm-AzBPApiManagementLogger -ResourceGroupName "rgbenchpresstest" -ServiceName "servicetest" `
        -Name "benchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$ServiceName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    # Unlike the other Get-AzApiManagement* cmdlets, Get-AzApiManagementLogger does not accept piping of the context
    $context = New-AzApiManagementContext -ResourceGroupName $ResourceGroupName -ServiceName $ServiceName
    $resource = Get-AzApiManagementLogger -Context $context -LoggerId $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-ApiManagementPolicy.ps1

function Confirm-ApiManagementPolicy {
  <#
    .SYNOPSIS
      Confirms that an API Management Policy exists.

    .DESCRIPTION
      The Confirm-AzBPApiManagementPolicy cmdlet gets an API Management Policy using the specified API, API Management
      Service, and Resource Group names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER ServiceName
      The name of the API Management Service.

    .PARAMETER ApiId
      The ID of the API. This cmdlet returns the API-scope policy.

    .EXAMPLE
      Confirm-AzBPApiManagementPolicy -ResourceGroupName "rgbenchpresstest" -ServiceName "servicetest" `
        -ApiId "benchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$ServiceName,

    [Parameter(Mandatory=$true)]
    [string]$ApiId
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $policy = New-AzApiManagementContext -ResourceGroupName $ResourceGroupName -ServiceName $ServiceName
    | Get-AzApiManagementPolicy -ApiId $ApiId

    # Get-AzApiManagementPolicy returns the XML for a policy, not a resource
    if ([string]::IsNullOrWhiteSpace($policy)) {
      $policy = $null
    }

    [ConfirmResult]::new($policy, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-AppInsights.ps1

function Confirm-AppInsights {
  <#
    .SYNOPSIS
      Confirms that an Application Insights exists.

    .DESCRIPTION
      The Confirm-AzBPAppInsights cmdlet gets an Application Insights using the specified Application Insights and
      Resource Group names.

    .PARAMETER Name
      The name of the Application Insights.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPAppInsights -Name "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '',
  Justification='App Insights is a name of an Azure resource and is not a plural noun')]
  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzApplicationInsights -ResourceGroupName $ResourceGroupName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-AppServicePlan.ps1

function Confirm-AppServicePlan {
  <#
    .SYNOPSIS
      Confirms that an App Service Plan exists.

    .DESCRIPTION
      The Confirm-AzBPAppServicePlan cmdlet gets an App Service Plan using the specified App Service Plan and
      Resource Group names.

    .PARAMETER AppServicePlanName
      The name of the App Service Plan.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPAppServicePlan -AppServicePlanName "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$AppServicePlanName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzAppServicePlan -ResourceGroupName $ResourceGroupName -Name $AppServicePlanName

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-BicepFile.ps1

function Confirm-BicepFile {
  <#
    .SYNOPSIS
      Confirm-AzBPBicepFile will confirm that the bicep files provided pass the checks executed by `bicep build`.

    .DESCRIPTION
      Confirm-AzBPBicepFile executes `bicep build` and returns an object that has an array field Errors. Each element
      of this array is an object that contains the bicep file path that had errors and a collection of
      System.Object.ErrorRecord that correspond to the file at that path:

      {Errors: [
          {Path: [string], ErrorResults: [ErrorRecord[]]}, {Path: [string], ErrorResults: [ErrorRecord[]]}, ...
        ]}

      Any errors will also be output to stdout for capture by CI/CD pipelines.

    .PARAMETER BicepPath
      This is the path to the bicep file that will be confirmed.
      BicepPath is a mandatory parameter.
      The property name is optional if the path is provided as the first argument to Confirm-AzBPBicepFile.

    .EXAMPLE
      Pipe path into Confirm-AzBPBicepFile.

      "./examples/actionGroupErrors.bicep" | Confirm-AzBPBicepFile

      Confirm-AzBPBicepFile: ../../../examples/actionGroupErrors.bicep:
      Confirm-AzBPBicepFile: /workspaces/benchpress/examples/actionGroupErrors.bicep(6,7) : Warning no-unused-params: Parameter "location" is declared but never used. [https://aka.ms/bicep/linter/no-unused-params]
      Confirm-AzBPBicepFile: /workspaces/benchpress/examples/actionGroupErrors.bicep(12,13) : Warning no-hardcoded-location: A resource location should not use a hard-coded string or variable value. Please use a parameter value, an expression, or the string 'global'. Found: 'westus' [https://aka.ms/bicep/linter/no-hardcoded-location]
      0

      Errors
      -----------
      {@{Path=../../../examples/actionGroupErrors.bicep; ErrorResults=System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject]...

    .EXAMPLE
      Pipe multiple paths into Confirm-AzBPBicepFile.

      "./examples/actionGroupErrors.bicep", "./examples/actionGroupErrors.bicep" | Confirm-AzBPBicepFile

      Confirm-AzBPBicepFile: ../../../examples/actionGroupErrors.bicep:
      Confirm-AzBPBicepFile: /workspaces/benchpress/examples/actionGroupErrors.bicep(6,7) : Warning no-unused-params: Parameter "location" is declared but never used. [https://aka.ms/bicep/linter/no-unused-params]
      Confirm-AzBPBicepFile: /workspaces/benchpress/examples/actionGroupErrors.bicep(12,13) : Warning no-hardcoded-location: A resource location should not use a hard-coded string or variable value. Please use a parameter value, an expression, or the string 'global'. Found: 'westus' [https://aka.ms/bicep/linter/no-hardcoded-location]
      0
      Confirm-AzBPBicepFile: ../../../examples/actionGroupErrors.bicep:
      Confirm-AzBPBicepFile: /workspaces/benchpress/examples/actionGroupErrors.bicep(6,7) : Warning no-unused-params: Parameter "location" is declared but never used. [https://aka.ms/bicep/linter/no-unused-params]
      Confirm-AzBPBicepFile: /workspaces/benchpress/examples/actionGroupErrors.bicep(12,13) : Warning no-hardcoded-location: A resource location should not use a hard-coded string or variable value. Please use a parameter value, an expression, or the string 'global'. Found: 'westus' [https://aka.ms/bicep/linter/no-hardcoded-location]
      1

      Errors
      -----------
      {@{Path=../../../examples/actionGroupErrors.bicep; ErrorResults=System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject]...

    .EXAMPLE
      Provide -BicepPath Parameter.

      Confirm-AzBPBicepFile -BicepPath ./examples/actionGroupErrors.bicep

      Confirm-AzBPBicepFile: ../../../examples/actionGroupErrors.bicep:
      Confirm-AzBPBicepFile: /workspaces/benchpress/examples/actionGroupErrors.bicep(6,7) : Warning no-unused-params: Parameter "location" is declared but never used. [https://aka.ms/bicep/linter/no-unused-params]
      Confirm-AzBPBicepFile: /workspaces/benchpress/examples/actionGroupErrors.bicep(12,13) : Warning no-hardcoded-location: A resource location should not use a hard-coded string or variable value. Please use a parameter value, an expression, or the string 'global'. Found: 'westus' [https://aka.ms/bicep/linter/no-hardcoded-location]
      0

      Errors
      -----------
      {@{Path=../../../examples/actionGroupErrors.bicep; ErrorResults=System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject]...

    .EXAMPLE
      Path without -BicepPath Parameter.

      Confirm-AzBPBicepFile ./examples/actionGroupErrors.bicep

      Confirm-AzBPBicepFile: ../../../examples/actionGroupErrors.bicep:
      Confirm-AzBPBicepFile: /workspaces/benchpress/examples/actionGroupErrors.bicep(6,7) : Warning no-unused-params: Parameter "location" is declared but never used. [https://aka.ms/bicep/linter/no-unused-params]
      Confirm-AzBPBicepFile: /workspaces/benchpress/examples/actionGroupErrors.bicep(12,13) : Warning no-hardcoded-location: A resource location should not use a hard-coded string or variable value. Please use a parameter value, an expression, or the string 'global'. Found: 'westus' [https://aka.ms/bicep/linter/no-hardcoded-location]
      0

      Errors
      -----------
      {@{Path=../../../examples/actionGroupErrors.bicep; ErrorResults=System.Collections.ObjectModel.Collection`1[System.Management.Automation.PSObject]...

    .INPUTS
      System.String[]

    .OUTPUTS
      System.Management.Automation.PSCustomObject[]
  #>

  [CmdletBinding()]
  [OutputType([System.Object[]])]
  param(
    [Parameter(Mandatory, Position=0, ValueFromPipeline)] [string[]]$BicepFilePath
  )
  Begin{
    $out = [PSCustomObject]@{
      Errors = New-Object System.Collections.ArrayList
    }
  }
  Process {
    foreach ($path in $BicepFilePath) {
      # The --stdout parameter will send the built ARM template to stdout instead of creating a file
      # 2>&1 will send errors to stdout so that they can be captured by PowerShell
      # Both the ARM template and any output from linting will be in the array $results, with individual errors in the
      # array separately
      $results = Invoke-Command -ScriptBlock { bicep build $path --stdout 2>&1 }
      # .Where() returns a collection of System.Management.Automation.ErrorRecord or null if there are no errors
      $errorResults = $results.Where({$PSItem.GetType().Name -eq 'ErrorRecord'})

      if ($errorResults.Count -gt 0) {
        Write-Error "${path}:"
        $errorResults | Write-Error

        $out.Errors.Add([PSCustomObject]@{Path = $path; ErrorResults = $errorResults})
      }
    }
  }
  End {
    $out
  }
}
# file Modules/BenchPress.Azure/Public/Confirm-ContainerApp.ps1

function Confirm-ContainerApp {
  <#
    .SYNOPSIS
      Confirms that a Container Application exists.

    .DESCRIPTION
      The Confirm-AzBPContainerApp cmdlet gets a Container Application using the specified Container Application and
      Resource Group names.

    .PARAMETER Name
      The name of the Container Application.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPContainerApp -Name "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzContainerApp -ResourceGroupName $ResourceGroupName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-ContainerAppManagedEnv.ps1

function Confirm-ContainerAppManagedEnv {
  <#
    .SYNOPSIS
      Confirms that a Container App Managed Environment exists.

    .DESCRIPTION
      The Confirm-AzBPContainerAppManagedEnv cmdlet gets a Managed Environment using the specified Managed Environment
      and Resource Group names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER Name
      The name of the Environment.

    .EXAMPLE
      Confirm-AzBPContainerAppManagedEnv -Name "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzContainerAppManagedEnv -ResourceGroupName $ResourceGroupName -EnvName $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-ContainerRegistry.ps1

function Confirm-ContainerRegistry {
  <#
    .SYNOPSIS
      Confirms that a Container Registry exists.

    .DESCRIPTION
      The Confirm-AzBPContainerRegistry cmdlet gets a Container Registry using the specified Container Registry and
      Resource Group names.

    .PARAMETER Name
      The name of the Container Registry.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPContainerRegistry -Name "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzContainerRegistry -ResourceGroupName $ResourceGroupName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-CosmosDBAccount.ps1

function Confirm-CosmosDBAccount {
  <#
    .SYNOPSIS
      Confirms that a Cosmos DB Account exists.

    .DESCRIPTION
      The Confirm-AzBPCosmosDBAccount cmdlet gets a Cosmos DB Account using the specified Resource Group and Cosmos DB
      Account names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER Name
      The name of the Cosmos DB Account.

    .EXAMPLE
      Confirm-AzBPCosmosDBAccount -Name "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzCosmosDBAccount -ResourceGroupName $ResourceGroupName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-CosmosDBGremlinDatabase.ps1

function Confirm-CosmosDBGremlinDatabase {
  <#
    .SYNOPSIS
      Confirms that a Cosmos DB Gremlin Database exists.

    .DESCRIPTION
      The Confirm-AzBPCosmosDBGremlinDatabase cmdlet gets a Cosmos DB Gremlin Database using the specified Resource
      Group, Cosmos DB Account, and Gremlin Database names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER AccountName
      The name of the Cosmos DB Account.

    .PARAMETER Name
      The name of the Cosmos DB Gremlin Database.

    .EXAMPLE
      Confirm-AzBPCosmosDBGremlinDatabase -ResourceGroupName "rgbenchpresstest" -AccountName "an" -Name "gremlindb"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$AccountName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $params = @{
      ResourceGroupName = $ResourceGroupName
      AccountName       = $AccountName
      Name              = $Name
    }
    $resource = Get-AzCosmosDBGremlinDatabase @params

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-CosmosDBMongoDBDatabase.ps1

function Confirm-CosmosDBMongoDBDatabase {
  <#
    .SYNOPSIS
      Confirms that a Cosmos DB Mongo DB Database exists.

    .DESCRIPTION
      The Confirm-CosmosDBMongoDBDatabase cmdlet gets Cosmos DB Mongo DB Database using the specified Resource Group,
      Cosmos DB Account, and Mongo DB Database names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER AccountName
      The name of the Cosmos DB Account.

    .PARAMETER Name
      The name of the Cosmos DB Mongo DB Database.

    .EXAMPLE
      Confirm-AzBPCosmosDBMongoDBDatabase -ResourceGroupName "rgbenchpresstest" -AccountName "an" -Name "mongodbdb"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$AccountName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $params = @{
      ResourceGroupName = $ResourceGroupName
      AccountName       = $AccountName
      Name              = $Name
    }
    $resource = Get-AzCosmosDBMongoDBDatabase @params

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-CosmosDBSqlDatabase.ps1

function Confirm-CosmosDBSqlDatabase {
  <#
    .SYNOPSIS
      Confirms that a Cosmos DB SQL Database exists.

    .DESCRIPTION
      The Confirm-AzBPCosmosDBSqlDatabase cmdlet gets a Cosmos DB SQL Database using the specified Resource Group,
      Cosmos DB Account, and SQL Database names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER AccountName
      The name of the Cosmos DB Account.

    .PARAMETER Name
      The name of the Cosmos DB SQL Database.

    .EXAMPLE
      Confirm-AzBPCosmosDBSqlDatabase -ResourceGroupName "rgbenchpresstest" -AccountName "an" -Name "sqldb"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$AccountName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzCosmosDBSqlDatabase -ResourceGroupName $ResourceGroupName -AccountName $AccountName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-CosmosDBSqlRoleAssignment.ps1

function Confirm-CosmosDBSqlRoleAssignment {
  <#
    .SYNOPSIS
      Confirms that a CosmosDB Sql Role Assignment exists.

    .DESCRIPTION
      The Confirm-AzBPCosmosDBSqlRoleAssignment cmdlet gets a CosmosDB Sql Role Assignment
      using the specified Resource Group Name, Cosmos DB Account Name and Role Assignment Id.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER AccountName
      The name of the Cosmos DB Account.

    .PARAMETER RoleAssignmentId
      The Id of the Role Assignment.

    .EXAMPLE
      $params = @{
        ResourceGroupName = "rgbenchpresstest"
        AccountName = "an"
        RoleAssignmentId = "roleassignmentid"
      }

      Confirm-AzBPCosmosDBSqlRoleAssignment @params

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$AccountName,

    [Parameter(Mandatory=$true)]
    [string]$RoleAssignmentId
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $params = @{
      ResourceGroupName = $ResourceGroupName
      AccountName       = $AccountName
      Id                = $RoleAssignmentId
    }
    $resource = Get-AzCosmosDBSqlRoleAssignment @params

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-CosmosDBSqlRoleDefinition.ps1

function Confirm-CosmosDBSqlRoleDefinition {
  <#
    .SYNOPSIS
      Confirms that a CosmosDB Sql Role Definition exists.

    .DESCRIPTION
      The Confirm-AzBPCosmosDBSqlRoleDefinition cmdlet gets a CosmosDB Sql Role Definition
      using the specified Resource Group Name, Cosmos DB Account Name and Role Definition Id.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER AccountName
      The name of the Cosmos DB Account.

    .PARAMETER RoleDefinitionId
      The Id of the Role Definition.

    .EXAMPLE
      $params = @{
        ResourceGroupName = "rgbenchpresstest"
        AccountName = "an"
        RoleDefinitionId = "roledefinitionid"
      }

      Confirm-AzBPCosmosDBSqlRoleDefinition @params

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$AccountName,

    [Parameter(Mandatory=$true)]
    [string]$RoleDefinitionId
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $params = @{
      ResourceGroupName = $ResourceGroupName
      AccountName       = $AccountName
      Id                = $RoleDefinitionId
    }
    $resource = Get-AzCosmosDBSqlRoleDefinition @params

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-DataFactory.ps1

function Confirm-DataFactory {
  <#
    .SYNOPSIS
      Confirms that a Data Factory exists.

    .DESCRIPTION
      The Confirm-AzBPDataFactory cmdlet gets a Data Factory using the specified Data Factory and
      Resource Group names.

    .PARAMETER Name
      The name of the Data Factory.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPDataFactory -Name "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzDataFactoryV2 -ResourceGroupName $ResourceGroupName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-DataFactoryLinkedService.ps1

function Confirm-DataFactoryLinkedService {
  <#
    .SYNOPSIS
      Confirms that a Data Factory exists.

    .DESCRIPTION
      The Confirm-AzBPDataFactoryLinkedService cmdlet gets a Data Factory Linked Service using the specified
      Data Factory, Linked Service, and Resource Group names.

    .PARAMETER Name
      The name of the Linked Service.

    .PARAMETER DataFactoryName
      The name of the Data Factory.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPDataFactoryLinkedService -Name "bplinkedservice" -ResourceGroupName "rgbenchpresstest" `
        -DataFactoryName "bpdatafactory"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$DataFactoryName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $params = @{
      ResourceGroupName = $ResourceGroupName
      DataFactoryName   = $DataFactoryName
      Name              = $Name
    }
    $resource = Get-AzDataFactoryV2LinkedService @params

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-DiagnosticSetting.ps1

function Confirm-DiagnosticSetting{
  <#
    .SYNOPSIS
      Confirms that a Diagnostic Setting exists.

    .DESCRIPTION
      The Confirm-AzBPDiagnosticSetting cmdlet gets a Diagnostic Setting using the specified Diagnostic Setting name
      and the specified Resource Id.

    .PARAMETER Name
      The name of the Diagnostic Setting.

    .PARAMETER ResourceId
      The Id of the Resource.

    .EXAMPLE
      Confirm-AzBPDiagnosticSetting -Name "benchpresstest"
      -ResourceId "/subscriptions/{subscriptionId}/resourceGroups/{rg}/providers/Microsoft.ContainerService/managedClusters/aksnqpog"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$ResourceId
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzDiagnosticSetting -ResourceId $ResourceId -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-EventHub.ps1

function Confirm-EventHub {
  <#
    .SYNOPSIS
      Confirms that an Event Hub exists.

    .DESCRIPTION
      The Confirm-AzBPEventHub cmdlet gets an Event Hub using the specified Event Hub, Event Hub Namespace,
      and Resource Group names.

    .PARAMETER Name
      The name of the Event Hub.

    .PARAMETER NamespaceName
      The name of the Event Hub Namespace.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPEventHub -Name "bpeventhub" -NamespaceName 'bpeventhubnamespace' -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$NamespaceName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzEventHub -ResourceGroupName $ResourceGroupName -NamespaceName $NamespaceName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-EventHubConsumerGroup.ps1

function Confirm-EventHubConsumerGroup {
  <#
    .SYNOPSIS
      Confirms that an EventHub ConsumerGroup exists.

    .DESCRIPTION
      The Confirm-AzBPEventHubConsumerGroup cmdlet gets an Event Hub Consumer Group using the specified Event Hub
      Consumer Group, Event Hub Namespace, Event Hub, and Resource Group names.

    .PARAMETER Name
      The name of the Event Hub Consumer Group.

    .PARAMETER NamespaceName
      The name of the Event Hub Namespace.

    .PARAMETER EventHubName
      The name of the Event Hub.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPEventHubConsumerGroup -Name 'consumergrouptest' -NamespaceName 'bpeventhubnamespace' -EventHubName 'bpeventhub' -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$NamespaceName,

    [Parameter(Mandatory=$true)]
    [string]$EventHubName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $params = @{
      Name              = $Name
      NamespaceName     = $NamespaceName
      EventHubName      = $EventHubName
      ResourceGroupName = $ResourceGroupName
    }

    $resource = Get-AzEventHubConsumerGroup @params

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-EventHubNamespace.ps1

function Confirm-EventHubNamespace {
  <#
    .SYNOPSIS
      Confirms that an Event Hub Namespace exists.

    .DESCRIPTION
      The Confirm-AzBPEventHubNamespace cmdlet gets an Event Hub Namespace using the specified Event Hub Namespace
      and Resource Group names.

    .PARAMETER NamespaceName
      The name of the Event Hub Namespace.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPEventHubNamespace -NamespaceName 'bpeventhubnamespace' -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$NamespaceName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzEventHubNamespace -ResourceGroupName $ResourceGroupName -NamespaceName $NamespaceName

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-KeyVault.ps1

function Confirm-KeyVault {
  <#
    .SYNOPSIS
      Confirms that a Key Vault exists.

    .DESCRIPTION
      The Confirm-AzBPKeyVault cmdlet gets a Key Vault using the specified Key Vault and Resource Group names.

    .PARAMETER Name
      The name of the Key Vault.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPKeyVault -Name "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory = $true)]
    [string]$Name,

    [Parameter(Mandatory = $true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzKeyVault -ResourceGroupName $ResourceGroupName -VaultName $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-KeyVaultCertificate.ps1

function Confirm-KeyVaultCertificate {
  <#
    .SYNOPSIS
      Confirms that a Key Vault Certificate exists.

    .DESCRIPTION
      The Confirm-AzBPKeyVaultCertificate cmdlet gets a Key Vault Certificate using the specified Key Vault and
      Certificate name.

    .PARAMETER Name
      The name of the Certificate.

    .PARAMETER KeyVaultName
      The name of the Key Vault.

    .EXAMPLE
      Confirm-AzBPKeyVaultCertificate -Name "benchpresstest" -KeyVaultName "kvbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory = $true)]
    [string]$Name,

    [Parameter(Mandatory = $true)]
    [string]$KeyVaultName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzKeyVaultCertificate -Name $Name -VaultName $KeyVaultName

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-KeyVaultKey.ps1

function Confirm-KeyVaultKey {
  <#
    .SYNOPSIS
      Confirms that a Key Vault Key exist.

    .DESCRIPTION
      The Confirm-AzBPKeyVaultKey cmdlet gets a Key Vault Key using the specified Key Vault and Key name.

    .PARAMETER Name
      The name of the Key.

    .PARAMETER KeyVaultName
      The name of the Key Vault.

    .EXAMPLE
      Confirm-AzBPKeyVaultKey -Name "benchpresstest" -KeyVaultName "kvbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory = $true)]
    [string]$Name,

    [Parameter(Mandatory = $true)]
    [string]$KeyVaultName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzKeyVaultKey -Name $Name -VaultName $KeyVaultName

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-KeyVaultSecret.ps1

function Confirm-KeyVaultSecret {
  <#
    .SYNOPSIS
      Confirms that a Key Vault Secret exists.

    .DESCRIPTION
      The Confirm-AzBPKeyVaultSecret cmdlet gets a Key Vault Secret using the specified Key Vault and Secret name.

    .PARAMETER Name
      The name of the Secret.

    .PARAMETER KeyVaultName
      The name of the Key Vault.

    .EXAMPLE
      Confirm-AzBPKeyVaultSecret -Name "benchpresstest" -KeyVaultName "kvbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory = $true)]
    [string]$Name,

    [Parameter(Mandatory = $true)]
    [string]$KeyVaultName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzKeyVaultSecret -Name $Name -VaultName $KeyVaultName

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-OperationalInsightsWorkspace.ps1

function Confirm-OperationalInsightsWorkspace {
  <#
    .SYNOPSIS
      Confirms that an Operational Insights Workspace exists.

    .DESCRIPTION
      The Confirm-AzBPOperationalInsightsWorkspace cmdlet gets an Operational Insights Workspace using the specified
      Workspace and Resource Group names.

    .PARAMETER Name
      The name of the Operational Insights Workspace.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPOperationalInsightsWorkspace -Name "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzOperationalInsightsWorkspace -ResourceGroupName $ResourceGroupName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-PortalDashboard.ps1

function Confirm-PortalDashboard {
  <#
    .SYNOPSIS
      Confirms that an Azure Dashboard exists.

    .DESCRIPTION
      The Confirm-AzBPPortalDashboard cmdlet gets an Azure Dashboard using the specified Dashboard and Resource Group names.

    .PARAMETER Name
      The name of the Azure Dashboard.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPPortalDashboard -Name "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzPortalDashboard -ResourceGroupName $ResourceGroupName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-PostgreSqlFlexibleServer.ps1

function Confirm-PostgreSqlFlexibleServer {
  <#
    .SYNOPSIS
      Confirms that a PostgreSQL Flexible Server exists.

    .DESCRIPTION
      The Confirm-AzBPPostgreSqlFlexibleServer cmdlet gets a PostgreSQL Flexible Server using the specified PostgreSQL
      Server Name and the Resource Group name.

    .PARAMETER ResourceGroupName
      The name of the resource group. The name is case insensitive.

    .PARAMETER Name
      The name of the server.

    .EXAMPLE
      Confirm-AzBPPostgreSqlFlexibleServer -ResourceGroupName "rgbenchpresstest" -Name "benchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzPostgreSqlFlexibleServer -ResourceGroupName $ResourceGroupName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}

# file Modules/BenchPress.Azure/Public/Confirm-Resource.ps1

function Confirm-Resource {
  <#
    .SYNOPSIS
      Confirms whether a resource exists or properties on a resource are configured correctly.

    .DESCRIPTION
      The Confirm-AzBPResource cmdlet confirms whether an Azure resource exists and/or confirms whether properties
      on a resource exist and are configured to the correct value. The cmdlet will return a ConfirmResult object
      which contains the following properties:
      - Success: True if the resource exists and/or the property is set to the expected value. Otherwise, false.
      - ResourceDetails: System.Object that contains the details of the Azure Resource that is being confirmed.

    .PARAMETER ResourceName
      The name of the Resource.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER ResourceType
      The type of the Resource as a [ResourceType].

    .PARAMETER ServerName
      If testing an Azure SQL Database resource, the name of the Server to which the Database is assigned.

    .PARAMETER DataFactoryName
      If testing an Azure Data Factory Linked Service resource, the name of the Data Factory to which the Linked
      Service is assigned.

    .PARAMETER NamespaceName
      If testing an Azure resource that is associated with a Namespace (e.g., Event Hub), the name of the associated
      Namespace.

    .PARAMETER EventHubName
      If testing a component of Event Hub (e.g., Consumer Group), the name of the Event Hub to which the component
      is assigned.

    .PARAMETER WorkspaceName
      If testing an Azure resource that belongs to some sort of Azure Workspace (e.g., SQL Pool in a Synapse
      Workspace), the name of the Workspace to which the resource is assigned.

    .PARAMETER AccountName
      If testing an Azure resource that is associated with an Account (e.g., Cosmos DB SQL Database,
      Storage Container), the name of the associated Account.

    .PARAMETER ServicePrincipalId
      If testing an Azure Role Assignment, the Enterprise/Managed Application Object ID of the Service Principal.

    .PARAMETER Scope
      If testing an Azure Role Assignment, the Scope of the Role Assignment (e.g.,
      /subscriptions/{id}/resourceGroups/{resourceGroupName}).
      It must start with "/subscriptions/{id}".

    .PARAMETER RoleDefinitionName
      If testing an Azure Role Assignment, the name of the Role Definition (e.g., Reader, Contributor etc.).

    .PARAMETER ServiceName
      If testing an Azure resource that is associated with a Service (e.g., API Management Service), the name of
      the associated Service.

    .PARAMETER KeyVaultName
      If testing an Azure Key Vault resource (e.g., Key Vault Key), the name of the Key Vault to which the resource is
      assigned.

    .PARAMETER JobName
      If testing an Azure resource that is associated with a Job (e.g., Stream Analytics Output), the name of
      the associated Job.

    .PARAMETER RoleAssignmentId
      If testing an Azure resource that is associated with a Role Assignment (e.g., Cosmos DB SQL Role Assignment),
      the id of the Role Assignment.

    .PARAMETER RoleDefinitionId
      If testing an Azure resource that is associated with a Role Definition (e.g., Cosmos DB SQL Role Definition),
      the id of the Role Definition.

    .PARAMETER ClusterName
      If testing an Azure resource that is associated with an AKS Cluster (e.g, AKS Node Pool) this is the parameter
      to use to pass the AKS cluster name.

    .PARAMETER ResourceId
      If testing an Azure resource that is associated with a Resource ID (e.g., Diagnostic Setting)
      this is the parameter to use to pass the Resource ID.

    .PARAMETER PropertyKey
      The name of the property to check on the resource.

    .PARAMETER PropertyValue
      The expected value of the property to check.

    .EXAMPLE
      Checking whether a resource exists (i.e. Resource Group).
      Confirm-AzBPResource -ResourceType $resourceType -ResourceName $resourceGroupName

    .EXAMPLE
      Confirm whether a resource has a property configured correctly (i.e. Resource Group located in West US 3).
      Confirm-AzBPResource -ResourceType $resourceType -ResourceName $resourceGroupName -PropertyKey "Location" `
                            -PropertyValue "WestUS3"

    .EXAMPLE
      Checking whether a nested property on a resource is configured correctly (i.e. OS of VM is Linux).

      $params = @{
        ResourceGroupName = "rg-test";
        ResourceType = "VirtualMachine";
        ResourceName = "testvm";
        PropertyKey = "StorageProfile.OsDisk.OsType";
        PropertyValue = "Linux"
      }

      $result = Confirm-AzBPResource @params

    .INPUTS
      ResourceType
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory = $false)]
    [string]$ResourceName,

    [Parameter(Mandatory = $false)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory = $true)]
    [ResourceType]$ResourceType,

    [Parameter(Mandatory = $false)]
    [string]$ServerName,

    [Parameter(Mandatory = $false)]
    [string]$KeyVaultName,

    [Parameter(Mandatory = $false)]
    [string]$DataFactoryName,

    [Parameter(Mandatory = $false)]
    [string]$NamespaceName,

    [Parameter(Mandatory = $false)]
    [string]$EventHubName,

    [Parameter(Mandatory = $false)]
    [string]$WorkspaceName,

    [Parameter(Mandatory = $false)]
    [string]$ServicePrincipalId,

    [Parameter(Mandatory = $false)]
    [string]$Scope,

    [Parameter(Mandatory = $false)]
    [string]$RoleDefinitionName,

    [Parameter(Mandatory = $false)]
    [string]$AccountName,

    [Parameter(Mandatory = $false)]
    [string]$ServiceName,

    [Parameter(Mandatory = $false)]
    [string]$ClusterName,

    [Parameter(Mandatory = $false)]
    [string]$JobName,

    [Parameter(Mandatory = $false)]
    [string]$ResourceId,

    [Parameter(Mandatory = $false)]
    [string]$RoleAssignmentId,

    [Parameter(Mandatory = $false)]
    [string]$RoleDefinitionId,

    [Parameter(Mandatory = $false)]
    [string]$PropertyKey,

    [Parameter(Mandatory = $false)]
    [string]$PropertyValue
  )
  Begin { }
  Process {
    $resourceParams = @{
      ResourceType       = $ResourceType
      NamespaceName      = $NamespaceName
      EventHubName       = $EventHubName
      JobName            = $JobName
      ResourceName       = $ResourceName
      ResourceGroupName  = $ResourceGroupName
      ServerName         = $ServerName
      KeyVaultName       = $KeyVaultName
      DataFactoryName    = $DataFactoryName
      WorkspaceName      = $WorkspaceName
      AccountName        = $AccountName
      RoleDefinitionName = $RoleDefinitionName
      Scope              = $Scope
      ServicePrincipalId = $ServicePrincipalId
      ServiceName        = $ServiceName
      RoleAssignmentId   = $RoleAssignmentId
      RoleDefinitionId   = $RoleDefinitionId
      ClusterName        = $ClusterName
      ResourceId         = $ResourceId
    }

    $confirmResult = Get-ResourceByType @resourceParams

    if ($null -eq $confirmResult) {
      Write-Error "Resource not found" -Category InvalidResult -ErrorId "InvalidResource"
      $confirmResult = [ConfirmResult]::new($null)
    } elseif ($confirmResult.Success -and -not [string]::IsNullOrWhiteSpace($PropertyKey)) {
      $actualValue = $confirmResult.ResourceDetails

      # Split property path on open and close square brackets and periods. Remove empty items from array.
      $keys = ($PropertyKey -split '[\[\]\.]').Where({ $_ -ne "" })
      foreach ($key in $keys) {
        # If key is a numerical value, index into array
        if ($key -match "^\d+$") {
          # Check to be sure the current $actualValue is an array and the index is present
          # Both arrays and lists that have indexers (generic lists as well) implement the IList interface
          if (-not ($actualValue -is [System.Collections.IList])) {
            # It is not indexable
            $errorParams = @{
              Message  = "The path '$PropertyKey' attempted to index into the [$($actualValue.GetType())] object " +
                "that does not implement the [IList] interface."
              Category = [System.Management.Automation.ErrorCategory]::InvalidArgument
              ErrorId  = "InvalidKey"
            }

            Write-Error @errorParams
            $confirmResult = [ConfirmResult]::new($null)
            break
          } elseif ([int]$key -lt 0 -or [int]$key -ge ([System.Collections.IList] $actualValue).Count) {
            # Index out of bounds
            $errorParams = @{
              Message  = "The path '$PropertyKey' with the index [$key] was out of bounds for the array with the " +
                "size $(([System.Collections.IList]$actualValue).Count)"
              Category = [System.Management.Automation.ErrorCategory]::InvalidArgument
              ErrorId  = "InvalidKey"
            }

            Write-Error @errorParams
            $confirmResult = [ConfirmResult]::new($null)
            break
          }

          $actualValue = $actualValue[$key]
        } else {
          # Check to be sure that the next key exists in the object, if it doesn't we fail
          if (-not [bool]($actualValue.PSObject.Properties.Name -match $key)) {
            # There is no property in the object with the key, fail.
            $errorParams = @{
              Message  = "The key '$key' in the path '$PropertyKey' does not exist in the " +
                "[$($confirmResult.ResourceDetails.GetType())] object."
              Category = [System.Management.Automation.ErrorCategory]::InvalidArgument
              ErrorId  = "InvalidKey"
            }

            Write-Error @errorParams
            $confirmResult = [ConfirmResult]::new($null)
            break
          }

          $actualValue = $actualValue.$key
        }
      }

      if ($PropertyValue -ne $null -and $confirmResult.Success -and $actualValue -ne $PropertyValue) {
        $confirmResult.Success = $false

        if ($null -eq $actualValue) {
          $errorParams = @{
            Message  = "A value for the property key: ${$PropertyKey}, was not found."
            Category = [System.Management.Automation.ErrorCategory]::InvalidArgument
            ErrorId  = "InvalidKey"
          }

          Write-Error @errorParams
        } else {
          $errorParams = @{
            Message  = "The value provided: ${$PropertyValue}, does not match the actual value: ${actualValue} for " +
                       "property key: ${$PropertyKey}"
            Category = [System.Management.Automation.ErrorCategory]::InvalidResult
            ErrorId  = "InvalidPropertyValue"
          }

          Write-Error @errorParams
        }
      }
    }

    $confirmResult
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-ResourceGroup.ps1

function Confirm-ResourceGroup {
  <#
    .SYNOPSIS
      Confirms that a Resource Group exists.

    .DESCRIPTION
      The Confirm-AzBPResourceGroup cmdlet gets a Resource Group using the specified Resource Group name.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPResourceGroup -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzResourceGroup $ResourceGroupName

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-RoleAssignment.ps1

function Confirm-RoleAssignment {
  <#
    .SYNOPSIS
      Confirms that a Role Assignment for a service principal exists.

    .DESCRIPTION
      The Confirm-AzBPRoleAssignment cmdlet gets a Role Assignment using the specified Service Prinicpal, Scope,
      and Role Assignment names.

    .PARAMETER RoleDefinitionName
      The name of the Role Definition i.e. Reader, Contributor etc.

    .PARAMETER ServicePrincipalId
      The Enterprise/Managed Application Object ID of the Service Principal.

    .PARAMETER Scope
      The Scope of the Role Assignment. In the format of relative URI. For e.g.
      /subscriptions/{id}/resourceGroups/{resourceGroupName}.
      It must start with "/subscriptions/{id}".

    .EXAMPLE
      Confirm-AzBPRoleAssignment -RoleDefinitionName Reader -ServicePrincipalName testId `
      -Scope /subscriptions/{id}/resourceGroups/{resourceGroupName}

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$RoleDefinitionName,

    [Parameter(Mandatory=$true)]
    [string]$ServicePrincipalId,

    [Parameter(Mandatory=$true)]
    [ValidatePattern("/subscriptions/.*")]
    [string]$Scope
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $params = @{
      ObjectId           = $ServicePrincipalId
      RoleDefinitionName = $RoleDefinitionName
      Scope              = $Scope
    }

    # Filter to specific scope specified by the parameter
    $resource = Get-AzRoleAssignment @params | Where-Object Scope -eq $Scope

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-SqlDatabase.ps1

function Confirm-SqlDatabase {
  <#
    .SYNOPSIS
      Confirms that a SQL Database exists.

    .DESCRIPTION
      The Confirm-AzBPSqlDatabase cmdlet gets a SQL Database using the specified SQL Database, SQL Server,
      and Resource Group names.

    .PARAMETER DatabaseName
      The name of the SQL Database.

    .PARAMETER DatabaseServer
      The name of the SQL Server.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPSqlDatabase -ServerName "testserver" -ResourceGroupName "rgbenchpresstest"

    .EXAMPLE
      Confirm-AzBPSqlDatabase -DatabaseName "testdb" -ServerName "testserver" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$DatabaseName,

    [Parameter(Mandatory=$true)]
    [string]$ServerName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $requestParams = @{
      ResourceGroupName = $ResourceGroupName
      ServerName        = $ServerName
      DatabaseName      = $DatabaseName
    }

    $resource = Get-AzSqlDatabase @requestParams

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-SqlServer.ps1

function Confirm-SqlServer {
  <#
    .SYNOPSIS
      Confirms that a SQL Server exists.

    .DESCRIPTION
      The Confirm-AzBPSqlServer cmdlet gets a SQL Server using the specified SQL Server and
      Resource Group names.

    .PARAMETER ServerName
      The name of the SQL Server.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPSqlServer -ServerName "testserver" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ServerName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
      $resource = Get-AzSqlServer -ResourceGroupName $ResourceGroupName -ServerName $ServerName

      [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-StorageAccount.ps1

function Confirm-StorageAccount {
  <#
    .SYNOPSIS
      Confirms that a Storage Account exists.

    .DESCRIPTION
      The Confirm-AzBPStorageAccount cmdlet gets a Storage Account using the specified Storage Account and
      Resource Group names.

    .PARAMETER Name
      The name of the Storage Account.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPStorageAccount -Name "teststorageaccount" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
      $resource = Get-AzStorageAccount -ResourceGroupName $ResourceGroupName -Name $Name

      [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-StorageContainer.ps1

function Confirm-StorageContainer {
  <#
    .SYNOPSIS
      Confirms that a Storage Container exists.

    .DESCRIPTION
      The Confirm-AzBPStorageContainer cmdlet gets a Storage Container using the specified Storage Account, Container,
      and Resource Group names.

    .PARAMETER Name
      The name of the Storage Container.

    .PARAMETER AccountName
      The name of the Storage Account.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPStorageContainer -Name "teststgcontainer" -AccountName "teststgacct" -ResourceGroupName "rg-test"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$AccountName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
      $resource = Get-AzStorageAccount -ResourceGroupName $ResourceGroupName -AccountName $AccountName
      | Get-AzStorageContainer -Name $Name

      [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-StreamAnalyticsCluster.ps1

function Confirm-StreamAnalyticsCluster {
  <#
    .SYNOPSIS
      Confirms that a Stream Analytics cluster exists.

    .DESCRIPTION
      The Confirm-AzBPStreamAnalyticsCluster cmdlet gets a Stream Analytics Cluster using the specified Cluster and
      Resource Group names.

    .PARAMETER Name
      The name of the Stream Analytics Cluster.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPStreamAnalyticsCluster -Name "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Name,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzStreamAnalyticsCluster -ResourceGroupName $ResourceGroupName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-StreamAnalyticsFunction.ps1

function Confirm-StreamAnalyticsFunction {
  <#
    .SYNOPSIS
      Confirms that a Stream Analytics Function exists.

    .DESCRIPTION
      The Confirm-AzBPStreamAnalyticsFunction cmdlet gets a Stream Analytics Function using the specified Resource
      Group, the Job executing the Function, and the Function names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER JobName
      The name of the Streaming Job.

    .PARAMETER Name
      The name of the Function.

    .EXAMPLE
      Confirm-AzBPStreamAnalyticsFunction -ResourceGroupName "rgbenchpresstest" -JobName "jn" -Name "benchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$JobName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzStreamAnalyticsFunction -ResourceGroupName $ResourceGroupName -JobName $JobName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-StreamAnalyticsInput.ps1

function Confirm-StreamAnalyticsInput {
  <#
    .SYNOPSIS
      Confirms that a Stream Analytics Input exists.

    .DESCRIPTION
      The Confirm-AzBPStreamAnalyticsInput cmdlet gets a Stream Analytics Input using the specified Resource Group, the
      Job with the Input, and the Input names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER JobName
      The name of the Streaming Job.

    .PARAMETER Name
      The name of the Input.

    .EXAMPLE
      Confirm-AzBPStreamAnalyticsInput -ResourceGroupName "rgbenchpresstest" -JobName "jn" -Name "benchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$JobName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzStreamAnalyticsInput -ResourceGroupName $ResourceGroupName -JobName $JobName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-StreamAnalyticsJob.ps1

function Confirm-StreamAnalyticsJob {
  <#
    .SYNOPSIS
      Confirms that a Stream Analytics Job exists.

    .DESCRIPTION
      The Confirm-AzBPStreamAnalyticsJob cmdlet gets a Stream Analytics Job using the specified Resource Group and
      Stream Analytics Job names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER Name
      The name of the Stream Analytics Job.

    .EXAMPLE
      Confirm-AzBPStreamAnalyticsCluster -ResourceGroupName "rgbenchpresstest" -Name "benchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzStreamAnalyticsJob -ResourceGroupName $ResourceGroupName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-StreamAnalyticsOutput.ps1

function Confirm-StreamAnalyticsOutput {
  <#
    .SYNOPSIS
      Confirms that a Stream Analytics Output exists.

    .DESCRIPTION
      The Confirm-AzBPStreamAnalyticsOutput cmdlet gets a Stream Analytics Output using the specified Resource Group,
      the Job with the Output, and the Output names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER JobName
      The name of the Streaming Job.

    .PARAMETER Name
      The name of the Output.

    .EXAMPLE
      Confirm-AzBPStreamAnalyticsOutput -ResourceGroupName "rgbenchpresstest" -JobName "jn" -Name "benchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$JobName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzStreamAnalyticsOutput -ResourceGroupName $ResourceGroupName -JobName $JobName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-StreamAnalyticsTransformation.ps1

function Confirm-StreamAnalyticsTransformation {
  <#
    .SYNOPSIS
      Confirms that a Stream Analytics Transformation exists.

    .DESCRIPTION
      The Confirm-AzBPStreamAnalyticsTransformation cmdlet gets a Stream Analytics Transformation using the specified
      Resource Group, the Job with the Transformation, and the Transformation names.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER JobName
      The name of the Streaming Job.

    .PARAMETER Name
      The name of the Transformation.

    .EXAMPLE
      Confirm-AzBPStreamAnalyticsTransformation -ResourceGroupName "rgbenchpresstest" -JobName "jn" `
        -Name "benchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory=$true)]
    [string]$JobName,

    [Parameter(Mandatory=$true)]
    [string]$Name
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzStreamAnalyticsTransformation -ResourceGroupName $ResourceGroupName -JobName $JobName -Name $Name

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-SynapseSparkPool.ps1

function Confirm-SynapseSparkPool {
  <#
    .SYNOPSIS
      Confirms that a Synapse Spark Pool exists.

    .DESCRIPTION
      The Confirm-AzBPSynapseSparkPool cmdlet gets a Spark Pool under a Synapse Workspace using the specified
      Synapse Workspace, Spark Pool, and Resource Group names.

    .PARAMETER SynapseSparkPoolName
      The name of the Spark Pool.

    .PARAMETER WorkspaceName
      The name of the Synapse Workspace.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPSynapseSparkPool -SynapseSparkPoolName "benchpresstest" -WorkspaceName "wstest" `
        -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$SynapseSparkPoolName,

    [Parameter(Mandatory=$true)]
    [string]$WorkspaceName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzSynapseSparkPool -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SynapseSparkPoolName

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-SynapseSqlPool.ps1

function Confirm-SynapseSqlPool {
  <#
    .SYNOPSIS
      Confirms that a Synapse SQL Pool exists.

    .DESCRIPTION
      The Confirm-AzBPSynapseSqlPool cmdlet gets a SQL Pool under a Synapse Workspace using the specified
      Synapse Workspace, SQL Pool, and Resource Group names.

    .PARAMETER SynapseSqlPoolName
      The name of the SQL Pool.

    .PARAMETER WorkspaceName
      The name of the Synapse Workspace.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPSynapseSqlPool -SynapseSqlPoolName "benchpresstest" -WorkspaceName "wstest" `
        -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$SynapseSqlPoolName,

    [Parameter(Mandatory=$true)]
    [string]$WorkspaceName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzSynapseSqlPool -ResourceGroupName $ResourceGroupName -WorkspaceName $WorkspaceName -Name $SynapseSqlPoolName

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-SynapseWorkspace.ps1

function Confirm-SynapseWorkspace {
  <#
    .SYNOPSIS
      Confirms that a Synapse Workspace exists.

    .DESCRIPTION
      The Confirm-AzBPSynapseWorkspace cmdlet gets a Synapse Workspace using the specified Synapse Workspace and
      Resource Group names.

    .PARAMETER WorkspaceName
      The name of the Synapse Workspace.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPSynapseWorkspace -WorkspaceName "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$WorkspaceName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
    $resource = Get-AzSynapseWorkspace -ResourceGroupName $ResourceGroupName -Name $WorkspaceName

    [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-VirtualMachine.ps1

function Confirm-VirtualMachine {
  <#
    .SYNOPSIS
      Confirms that a Virtual Machine exists.

    .DESCRIPTION
      The Confirm-AzBPVirtualMachine cmdlet gets a Virtual Machine using the specified Virtual Machine and
      Resource Group names.

    .PARAMETER VirtualMachineName
      The name of the Virtual Machine.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPVirtualMachine -VirtualMachineName "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$VirtualMachineName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
      $resource = Get-AzVM -ResourceGroupName $ResourceGroupName -Name $VirtualMachineName

      [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-WebApp.ps1

function Confirm-WebApp {
  <#
    .SYNOPSIS
      Confirms that a Web App exists.

    .DESCRIPTION
      The Confirm-AzBPWebApp cmdlet gets a Web App using the specified Web App and Resource Group names.

    .PARAMETER WebAppName
      The name of the Web App.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Confirm-AzBPWebApp -WebAppName "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$WebAppName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
      $resource = Get-AzWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName

      [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Confirm-WebAppStaticSite.ps1

function Confirm-WebAppStaticSite {
  <#
    .SYNOPSIS
      Confirms that a Web App Static Site exists.

    .DESCRIPTION
      The Confirm-AzBPWebAppStaticSite cmdlet gets a Web App Static Site using the specified Web App and
      Resource Group names.

    .PARAMETER StaticWebAppName
      The name of the Web App Static Site.

    .PARAMETER ResourceGroupName
      The name of the Resource Group.

    .EXAMPLE
      Confirm-AzBPWebAppStaticSite -StaticWebAppName "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory=$true)]
    [string]$StaticWebAppName,

    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )
  Begin {
    $connectResults = Connect-Account
  }
  Process {
      $resource = Get-AzStaticWebApp -ResourceGroupName $ResourceGroupName -Name $StaticWebAppName

      [ConfirmResult]::new($resource, $connectResults.AuthenticationData)
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Deploy-BicepFeature.ps1

function Deploy-BicepFeature(){
  <#
    .SYNOPSIS
      Deploys Azure resources using a bicep file.

    .DESCRIPTION
      Deploy-AzBPBicepFeature cmdlet deploys Azure resources when given a path to a bicep file. The cmdlet will
      transpile the bicep file to an ARM template and uses the ARM template to deploy to Azure.

    .PARAMETER BicepPath
      This is the path to the bicep file that will be used to transpile to ARM and deploy to Azure.

    .EXAMPLE
      $params = @{
        name = "acrbenchpresstest1"
        location = "westus3"
      }
      Deploy-AzBPBicepFeature -BicepPath "./containerRegistry.bicep" -Params $params -ResourceGroupName "rg-test"

    .INPUTS
      System.String
      System.Collections.Hashtable

    .OUTPUTS
      None
  #>

  [CmdletBinding()]
  param (
    [Parameter(Mandatory=$true)]
    [string]$BicepPath,

    [Parameter(Mandatory=$true)]
    [hashtable]$Params,

    [Parameter(Mandatory=$false)]
    [string]$ResourceGroupName
  )
  $fileName = [System.IO.Path]::GetFileNameWithoutExtension($BicepPath)
  $folder = Split-Path $BicepPath
  $armPath  = Join-Path -Path $folder -ChildPath "$fileName.json"

  Connect-Account

  Write-Information "Transpiling Bicep to Arm"
  # 2>&1 will send errors to stdout so that they can be captured by PowerShell
  # Both the ARM template and any output from linting will be in the array $results, with individual errors in the
  # array separately
  $results = Invoke-Command -ScriptBlock { bicep build $BicepPath 2>&1 }
  # .Where() returns a collection of System.Management.Automation.ErrorRecord or null if there are no errors
  $errorResults = $results.Where({$PSItem.GetType().Name -eq 'ErrorRecord'})

  # Only deploy if there are no errors.
  if ($errorResults.Count -eq 0) {
    $location = $Params.location
    $deploymentName = $Params.deploymentName

    if ([string]::IsNullOrEmpty($deploymentName)) {
      $deploymentName = "BenchPressDeployment"
    }

    Write-Information "Deploying ARM Template ($deploymentName) to $location"

    if ([string]::IsNullOrEmpty($ResourceGroupName)) {
      New-AzSubscriptionDeployment -Name "$deploymentName" -Location "$location" -TemplateFile "$armPath" -TemplateParameterObject $Params -SkipTemplateParameterPrompt
    }
    else{
      New-AzResourceGroupDeployment -Name "$deploymentName" -ResourceGroupName "$ResourceGroupName" -TemplateFile "$armPath" -TemplateParameterObject $Params -SkipTemplateParameterPrompt
    }
  }

  Write-Information "Removing Arm template json"
  Remove-Item "$armPath"
}
# file Modules/BenchPress.Azure/Public/Get-Resource.ps1

function Get-Resource {
  <#
    .SYNOPSIS
      Gets one or more resources of a given name.

    .DESCRIPTION
      The Get-AzBPResource cmdlet gets Azure resources of a given name.

    .PARAMETER ResourceName
      The name of the Resource.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .EXAMPLE
      Get-AzBPResource -ResourceName "benchpresstest"

    .EXAMPLE
      Get-AzBPResource -ResourceName "benchpresstest" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      Microsoft.Azure.Commands.ResourceManager.Cmdlets.SdkModels.PSResource
  #>

  [CmdletBinding()]
  param (
    [Parameter(Mandatory = $true)]
    [string]$ResourceName,

    [Parameter(Mandatory = $false)]
    [string]$ResourceGroupName
  )
  Begin {
    Connect-Account
  }
  Process {
    if ([string]::IsNullOrEmpty($ResourceGroupName)) {
      return Get-AzResource -Name $ResourceName
    }
    else {
      return Get-AzResource -Name $ResourceName -ResourceGroupName $ResourceGroupName
    }
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Get-ResourceByType.ps1

function Get-ResourceByType {
  <#
    .SYNOPSIS
      Gets an Azure Resource.

    .DESCRIPTION
      The Get-AzBPResourceByType cmdlet gets an Azure resource depending on the resource type (i.e. Action Group, Key Vault,
      Container Registry, etc.).

    .PARAMETER ResourceName
      The name of the Resource.

    .PARAMETER ResourceGroupName
      The name of the Resource Group. The name is case insensitive.

    .PARAMETER ResourceType
      The type of the Resource.

    .PARAMETER ServerName
      If testing an Azure SQL Database resource, the name of the Server to which the Database is assigned.

    .PARAMETER KeyVaultName
      If testing an Azure Key Vault resource (e.g., Key Vault Key), the name of the Key Vault to which the resource is
      assigned.

    .PARAMETER DataFactoryName
      If testing an Azure Data Factory Linked Service resource, the name of the Data Factory to which the Linked
      Service is assigned.

    .PARAMETER NamespaceName
      If testing an Azure resource that is associated with a Namespace (e.g., Event Hub), the name of the associated
      Namespace.

    .PARAMETER EventHubName
      If testing a component of Event Hub (e.g., Consumer Group), the name of the Event Hub to which the component
      is assigned.

    .PARAMETER WorkspaceName
      If testing an Azure resource that belongs to some sort of Azure Workspace (e.g., SQL Pool in a Synapse
      Workspace), the name of the Workspace to which the resource is assigned.

    .PARAMETER AccountName
      If testing an Azure resource that is associated with an Account (e.g., Cosmos DB SQL Database,
      Storage Container), the name of the associated Account.

    .PARAMETER ServicePrincipalId
      If testing an Azure Role Assignment, the Enterprise/Managed Application Object ID of the Service Principal.

    .PARAMETER Scope
      If testing an Azure Role Assignment, the Scope of the Role Assignment (e.g.,
      /subscriptions/{id}/resourceGroups/{resourceGroupName}).
      It must start with "/subscriptions/{id}".

    .PARAMETER RoleDefinitionName
      If testing an Azure Role Assignment, the name of the Role Definition (e.g., Reader, Contributor etc.).

    .PARAMETER ServiceName
      If testing an Azure resource that is associated with a Service (e.g., API Management Service),
      the name of the associated Service.

    .PARAMETER RoleAssignmentId
      If testing an Azure resource that is associated with a Role Assignment (e.g., Cosmos DB SQL Role Assignment),
      the name of the associated Role Assignment.

    .PARAMETER RoleDefinitionId
      If testing an Azure resource that is associated with a Role Definition (e.g., Cosmos DB SQL Role Definition),
      the name of the associated Role Definition.

    .PARAMETER JobName
      If testing an Azure resource that is associated with a Job (e.g., Stream Analytics Output), the name of
      the associated Job.

    .PARAMETER ClusterName
      If the Azure resource is associated with an AKS Cluster (e.g, AKS Node Pool), this is the parameter to use to pass
      the AKS cluster name.

    .PARAMETER ResourceId
      If testing an Azure resource that is associated with a Resource ID (e.g., Diagnostic Setting)
      this is the parameter to use to pass the Resource ID.

    .EXAMPLE
      Get-AzBPResourceByType -ResourceType ActionGroup -ResourceName "bpactiongroup" -ResourceGroupName "rgbenchpresstest"

    .EXAMPLE
      Get-AzBPResourceByType -ResourceType VirtualMachine -ResourceName "testvm" -ResourceGroupName "rgbenchpresstest"

    .INPUTS
      System.String

    .OUTPUTS
      ConfirmResult
  #>

  [CmdletBinding()]
  [OutputType([ConfirmResult])]
  param (
    [Parameter(Mandatory = $false)]
    [string]$ResourceName,

    [Parameter(Mandatory = $false)]
    [string]$ResourceGroupName,

    [Parameter(Mandatory = $true)]
    [ResourceType]$ResourceType,

    [Parameter(Mandatory = $false)]
    [string]$ServerName,

    [Parameter(Mandatory = $false)]
    [string]$KeyVaultName,

    [Parameter(Mandatory = $false)]
    [string]$DataFactoryName,

    [Parameter(Mandatory = $false)]
    [string]$NamespaceName,

    [Parameter(Mandatory = $false)]
    [string]$EventHubName,

    [Parameter(Mandatory = $false)]
    [string]$WorkspaceName,

    [Parameter(Mandatory = $false)]
    [string]$AccountName,

    [Parameter(Mandatory = $false)]
    [string]$ServicePrincipalId,

    [Parameter(Mandatory = $false)]
    [string]$Scope,

    [Parameter(Mandatory = $false)]
    [string]$RoleDefinitionName,

    [Parameter(Mandatory = $false)]
    [string]$ServiceName,

    [Parameter(Mandatory = $false)]
    [string]$JobName,

    [Parameter(Mandatory = $false)]
    [string]$ClusterName,

    [Parameter(Mandatory = $false)]
    [string]$ResourceId,

    [Parameter(Mandatory = $false)]
    [string]$RoleAssignmentId,

    [Parameter(Mandatory = $false)]
    [string]$RoleDefinitionId
  )
  Begin { }
  Process {
    switch ($ResourceType) {
      "ActionGroup" {
        return Confirm-ActionGroup -ActionGroupName $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "AksCluster" {
        return Confirm-AksCluster -AKSName $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "AksNodePool" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          ClusterName       = $ClusterName
          Name              = $ResourceName
        }
        return Confirm-AksNodePool @params
      }
      "ApiManagement" {
        return Confirm-ApiManagement -ResourceGroupName $ResourceGroupName -Name $ResourceName
      }
      "ApiManagementApi" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          ServiceName       = $ServiceName
          Name              = $ResourceName
        }
        return Confirm-ApiManagementApi @params
      }
      "ApiManagementDiagnostic" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          ServiceName       = $ServiceName
          Name              = $ResourceName
        }
        return Confirm-ApiManagementDiagnostic @params
      }
      "ApiManagementLogger" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          ServiceName       = $ServiceName
          Name              = $ResourceName
        }
        return Confirm-ApiManagementLogger @params
      }
      "ApiManagementPolicy" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          ServiceName       = $ServiceName
          ApiId             = $ResourceName
        }
        return Confirm-ApiManagementPolicy @params
      }
      "AppInsights" {
        return Confirm-AppInsights -ResourceGroupName $ResourceGroupName -Name $ResourceName
      }
      "AppServicePlan" {
        return Confirm-AppServicePlan -AppServicePlanName $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "ContainerApp" {
        return Confirm-ContainerApp -ResourceGroupName $ResourceGroupName -Name $ResourceName
      }
      "ContainerAppManagedEnv" {
        return Confirm-ContainerAppManagedEnv -ResourceGroupName $ResourceGroupName -Name $ResourceName
      }
      "ContainerRegistry" {
        return Confirm-ContainerRegistry -Name $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "CosmosDBAccount" {
        return Confirm-CosmosDBAccount -ResourceGroupName $ResourceGroupName -Name $ResourceName
      }
      "CosmosDBGremlinDatabase" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          AccountName       = $AccountName
          Name              = $ResourceName
        }
        return Confirm-CosmosDBGremlinDatabase @params
      }
      "CosmosDBMongoDBDatabase" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          AccountName       = $AccountName
          Name              = $ResourceName
        }
        return Confirm-CosmosDBMongoDBDatabase @params
      }
      "CosmosDBSqlDatabase" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          AccountName       = $AccountName
          Name              = $ResourceName
        }
        return Confirm-CosmosDBSqlDatabase @params
      }
      "CosmosDBSqlRoleAssignment" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          AccountName       = $AccountName
          RoleAssignmentId  = $RoleAssignmentId
        }
        return Confirm-CosmosDBSqlRoleAssignment @params
      }
      "CosmosDBSqlRoleDefinition" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          AccountName       = $AccountName
          RoleDefinitionId  = $RoleDefinitionId
        }
        return Confirm-CosmosDBSqlRoleDefinition @params
      }
      "DataFactory" {
        return Confirm-DataFactory -Name $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "DataFactoryLinkedService" {
        $params = @{
          Name              = $ResourceName
          DataFactoryName   = $DataFactoryName
          ResourceGroupName = $ResourceGroupName
        }
        return Confirm-DataFactoryLinkedService @params
      }
      "DiagnosticSetting" {
        return Confirm-DiagnosticSetting -ResourceId $ResourceId -Name $ResourceName
      }
      "EventHub" {
        $params = @{
          Name              = $ResourceName
          NamespaceName     = $NamespaceName
          ResourceGroupName = $ResourceGroupName
        }
        return Confirm-EventHub @params
      }
      "EventHubConsumerGroup" {
        $params = @{
          Name              = $ResourceName
          EventHubName      = $EventHubName
          NamespaceName     = $NamespaceName
          ResourceGroupName = $ResourceGroupName
        }
        return Confirm-EventHubConsumerGroup @params
      }
      "EventHubNamespace" {
        return Confirm-EventHubNamespace -NamespaceName $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "KeyVault" {
        return Confirm-KeyVault -Name $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "KeyVaultCertificate" {
        return Confirm-KeyVaultCertificate -KeyVaultName $KeyVaultName -Name $ResourceName
      }
      "KeyVaultKey" {
        return Confirm-KeyVaultKey -KeyVaultName $KeyVaultName -Name $ResourceName
      }
      "KeyVaultSecret" {
        return Confirm-KeyVaultSecret -KeyVaultName $KeyVaultName -Name $ResourceName
      }
      "OperationalInsightsWorkspace" {
        return Confirm-OperationalInsightsWorkspace -Name $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "PortalDashboard" {
        return Confirm-PortalDashboard -ResourceGroupName $ResourceGroupName -Name $ResourceName
      }
      "PostgreSqlFlexibleServer" {
        return Confirm-PostgreSqlFlexibleServer -ResourceGroupName $ResourceGroupName -Name $ResourceName
      }
      "ResourceGroup" {
        return Confirm-ResourceGroup -ResourceGroupName $ResourceName
      }
      "RoleAssignment" {
        $params = @{
          ServicePrincipalId   = $ServicePrincipalId
          RoleDefinitionName   = $RoleDefinitionName
          Scope                = $Scope
        }
        return Confirm-RoleAssignment @params
      }
      "SqlDatabase" {
        $params = @{
          ServerName        = $ServerName
          DatabaseName      = $ResourceName
          ResourceGroupName = $ResourceGroupName
        }
        return Confirm-SqlDatabase @params
      }
      "SqlServer" {
        return Confirm-SqlServer -ServerName $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "StorageAccount" {
        return Confirm-StorageAccount -Name $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "StorageContainer" {
        $params = @{
          Name              = $ResourceName
          AccountName       = $AccountName
          ResourceGroupName = $ResourceGroupName
        }
        return Confirm-StorageContainer @params
      }
      "StreamAnalyticsCluster" {
        return Confirm-StreamAnalyticsCluster -Name $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "StreamAnalyticsFunction" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          JobName           = $JobName
          Name              = $ResourceName
        }
        return Confirm-StreamAnalyticsFunction @params
      }
      "StreamAnalyticsInput" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          JobName           = $JobName
          Name              = $ResourceName
        }
        return Confirm-StreamAnalyticsInput @params
      }
      "StreamAnalyticsJob" {
        return Confirm-StreamAnalyticsJob -ResourceGroupName $ResourceGroupName -Name $ResourceName
      }
      "StreamAnalyticsOutput" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          JobName           = $JobName
          Name              = $ResourceName
        }
        return Confirm-StreamAnalyticsOutput @params
      }
      "StreamAnalyticsTransformation" {
        $params = @{
          ResourceGroupName = $ResourceGroupName
          JobName           = $JobName
          Name              = $ResourceName
        }
        return Confirm-StreamAnalyticsTransformation @params
      }
      "SynapseSparkPool" {
        $params = @{
          SynapseSparkPoolName = $ResourceName
          WorkspaceName        = $WorkspaceName
          ResourceGroupName    = $ResourceGroupName
        }
        return Confirm-SynapseSparkPool @params
      }
      "SynapseSqlPool" {
        $params = @{
          SynapseSqlPoolName = $ResourceName
          WorkspaceName      = $WorkspaceName
          ResourceGroupName  = $ResourceGroupName
        }
        return Confirm-SynapseSqlPool @params
      }
      "SynapseWorkspace" {
        return Confirm-SynapseWorkspace -WorkspaceName $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "VirtualMachine" {
        return Confirm-VirtualMachine -VirtualMachineName $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "WebApp" {
        return Confirm-WebApp -WebAppName $ResourceName -ResourceGroupName $ResourceGroupName
      }
      "WebAppStaticSite" {
        return Confirm-WebAppStaticSIte -StaticWebAppName $ResourceName -ResourceGroupName $ResourceGroupName
      }
      default {
        Write-Information "Not implemented yet"
        return $null
      }
    }
  }
  End { }
}
# file Modules/BenchPress.Azure/Public/Invoke-AzCli.ps1
function Invoke-AzCli {
  <#
    .DESCRIPTION
    Invoke an Azure CLI command.

    .SYNOPSIS
    Invoke-AzBPAzCli cmdlet invokes an Azure CLI command and returns the result as an object.

    .EXAMPLE
    PS C:\> Invoke-AzBPAzCli "account list"

    .EXAMPLE
    PS C:\> Invoke-AzBPAzCli "account list --query [].name"

    .EXAMPLE
    PS C:\> Invoke-AzBPAzCli "webapp create --name ${WEBAPP_NAME} --resource-group ${RESOURCE_GROUP_NAME} --plan ${APP_SERVICE_PLAN_NAME}"

    .PARAMETER Command
    The command to execute.

    .NOTES
    Invoke-AzBPAzCli adds the az prefix to the command.

    .LINK
    https://learn.microsoft.com/en-us/cli/azure/

    .LINK
    https://learn.microsoft.com/en-us/cli/azure/get-started-with-azure-cli

    .LINK
    https://learn.microsoft.com/en-us/cli/azure/reference-index?view=azure-cli-latest

    .INPUTS
    System.String

    .OUTPUTS
    System.Object
  #>

  [CmdletBinding()]
  [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingInvokeExpression", "")]
  param (
    [Parameter(Mandatory=$true)]
    [string]$Command
  )

  $toExecute = "az $Command"

  $result = Invoke-Expression "$toExecute"

  if ($LastExitCode -gt 0) {
    Write-Error "$result"
  } else {
    $result | ConvertFrom-Json
  }
}
# file Modules/BenchPress.Azure/Public/Remove-BicepFeature.ps1

function Remove-BicepFeature(){
  <#
    .SYNOPSIS
      Deletes Azure resources.

    .DESCRIPTION
      Remove-AzBPBicepFeature cmdlet will take an Azure Resource Group name and delete that resource group and all
      resources contained in it.

    .PARAMETER ResourceGroupName
      The name of the Resource Group to delete. The name is case insensitive.

    .EXAMPLE
      Remove-AzBPBicepFeature -ResourceGroupName "rg-test"

    .INPUTS
      System.String

    .OUTPUTS
      None
  #>

  [CmdletBinding()]
  [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
  param (
    [Parameter(Mandatory=$true)]
    [string]$ResourceGroupName
  )

  Connect-Account

  $resourceGroup = Get-AzResourceGroup -Name $ResourceGroupName
  Remove-AzResourceGroup -Name $resourceGroup.ResourceGroupName -Force
}
# file Modules/BenchPress.Azure/Public/CustomAssertions/BeInLocation.ps1
function ShouldBeInLocation ($ActualValue, [string]$ExpectedValue, [switch] $Negate, [string] $Because) {
  <#
    .SYNOPSIS
      Custom Assertion function to check status on a resource deployment.

    .DESCRIPTION
      BeInLocation is a custom assertion that checks the provided ConfirmResult Object for deployment success.
      It can be used when writing Pester tests.

    .EXAMPLE
      Confirm-AzBPResourceGroup -ResourceGroupName $rgName | Should -BeInLocation 'westus3'

    .EXAMPLE
      Confirm-AzBPResourceGroup -ResourceGroupName $rgName | Should -Not -BeInLocation 'westus2'

    .INPUTS
      ConfirmResult
      System.Switch
      System.String

    .OUTPUTS
      PSCustomObject
  #>

  $propertyName = 'Location'

  if ($null -eq $ActualValue){
    [bool] $succeeded = $false
    $failureMessage = "ConfirmResult is null or empty."
  } elseif (-not [bool]$ActualValue.ResourceDetails.PSObject.Properties[$propertyName]) {
    [bool] $succeeded = $false
    $failureMessage = "Resource does not have a location property. It is null or empty."
  } else {
    # Both expected and actual locations should be normalized with no spaces
    $resourceLocation = $ActualValue.ResourceDetails.Location -replace " ",""
    $expectedLocation = $ExpectedValue -replace " ",""

    [bool] $succeeded = $resourceLocation -ieq $expectedLocation
    if ($Negate) { $succeeded = -not $succeeded }

    if (-not $succeeded) {
      if ($Negate) {
        $failureMessage = "Resource is deployed, incorrectly, in $resourceLocation."
      } else {
        $failureMessage = "Resource not in location or there was an error when confirming resource.
        Expected $ExpectedValue but got $resourceLocation."

        if ($Because) { $failureMessage = "Resource not in location $Because." }
      }
    }
  }

  return [pscustomobject]@{
      Succeeded      = $succeeded
      FailureMessage = $failureMessage
  }
}

Add-ShouldOperator -Name BeInLocation `
    -InternalName 'ShouldBeInLocation' `
    -Test ${function:ShouldBeInLocation} `
    -Alias 'SBIL'
# file Modules/BenchPress.Azure/Public/CustomAssertions/BeInResourceGroup.ps1
function ShouldBeInResourceGroup ($ActualValue, [string]$ExpectedValue, [switch] $Negate, [string] $Because) {
  <#
    .SYNOPSIS
      Custom Assertion function to check resource's resource group.

    .DESCRIPTION
      BeInResourceGroup is a custom assertion that checks the resource group of a resource.
      It can be used when writing Pester tests.

    .EXAMPLE
      Confirm-AzBPContainerRegistry -ResourceGroupName $rgName | Should -BeInResourceGroup 'rg-test'

    .EXAMPLE
      Confirm-AzBPContainerRegistry -ResourceGroupName $rgName | Should -Not -BeInResourceGroup 'rg-test2'

    .INPUTS
      ConfirmResult
      System.Switch
      System.String

    .OUTPUTS
      PSCustomObject
  #>

  $rgProperty = 'ResourceGroup'
  $rgNameProperty = 'ResourceGroupName'
  $idProperty = 'Id'

  if ($null -eq $ActualValue){
    [bool] $succeeded = $false
    $failureMessage = "ConfirmResult is null or empty."
  } else {
    if ([bool]$ActualValue.ResourceDetails.PSObject.Properties[$rgProperty]){
      $resourceGroupName = $ActualValue.ResourceDetails.$rgProperty
    } elseif ([bool]$ActualValue.ResourceDetails.PSObject.Properties[$rgNameProperty]){
      $resourceGroupName = $ActualValue.ResourceDetails.$rgNameProperty
    } elseif ([bool]$ActualValue.ResourceDetails.PSObject.Properties[$idProperty]){
      # If it does not have a property for resource group, then we can maybe get the resource group from Id
      # ex: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/'
      # providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
      $resourceId = $ActualValue.ResourceDetails.$idProperty
      $resourceGroupPath = $resourceId -split 'resourceGroups' | Select-Object -Last 1
      $resourceGroupName = @($resourceGroupPath -split '/')[1]

      # If $resourceGroupName is empty, the Id is the wrong format
      # so, set it to null
      if ('' -eq $resourceGroupName) {
        $resourceGroupName = $null
      }
    }

    # Some resources don't have any of the resource group properties
    if ($null -eq $resourceGroupName){
      [bool] $succeeded = $false
      $failureMessage = "Resource does not have a ResourceGroup, a ResourceGroupName, or an Id (with a RG) property.
      They are null or empty."

    } else {
        [bool] $succeeded = $resourceGroupName -eq $ExpectedValue
        if ($Negate) { $succeeded = -not $succeeded }

        if (-not $succeeded) {
            if ($Negate) {
              $failureMessage = "Resource is deployed, incorrectly, in $resourceGroupName."
            } else {
              $failureMessage = "Resource not in resource group or there was an error when confirming resource.
              Expected $ExpectedValue but got $resourceGroupName."

              if ($Because) { $failureMessage = "Resource not in resource group. This failed $Because." }
            }
        }
    }
  }

  return [pscustomobject]@{
      Succeeded      = $succeeded
      FailureMessage = $failureMessage
  }
}

Add-ShouldOperator -Name BeInResourceGroup `
    -InternalName 'ShouldBeInResourceGroup' `
    -Test ${function:ShouldBeInResourceGroup} `
    -Alias 'SBIRG'
# file Modules/BenchPress.Azure/Public/CustomAssertions/BeSuccessful.ps1
function ShouldBeSuccessful ($ActualValue, [switch] $Negate, [string] $Because) {
  <#
    .SYNOPSIS
      Custom Assertion function to check status on a resource deployment.

    .DESCRIPTION
      BeSuccessful is a custom assertion that checks the provided ConfirmResult Object for deployment success.
      It can be used when writing Pester tests.

    .EXAMPLE
      Confirm-AzBPResourceGroup -ResourceGroupName $rgName | Should -BeSuccessful

    .EXAMPLE
      Confirm-AzBPResourceGroup -ResourceGroupName $rgName | Should -Not -BeSuccessful

    .INPUTS
      ConfirmResult
      System.Switch
      System.String

    .OUTPUTS
      PSCustomObject
  #>

  if ($null -eq $ActualValue){
    [bool] $succeeded = $false
    $failureMessage = "ConfirmResult is null or empty."
  } else {
    [bool] $succeeded = $ActualValue.Success
    if ($Negate) { $succeeded = -not $succeeded }

    if (-not $succeeded) {
      if ($Negate) {
        $failureMessage = "Resource is currently deployed, but should not be."
      } else {
        $failureMessage = "Resource not deployed or there was an error when confirming resource."
        if ($Because) { $failureMessage = "Resource not available $Because." }
      }
    }
  }

  return [pscustomobject]@{
    Succeeded      = $succeeded
    FailureMessage = $failureMessage
  }
}

Add-ShouldOperator -Name BeSuccessful `
    -InternalName 'ShouldBeSuccessful' `
    -Test ${function:ShouldBeSuccessful} `
    -Alias 'SBS'
# file Modules/BenchPress.Azure/Private/Connect-Account.ps1

function Connect-Account {
  <#
    .SYNOPSIS
      Connect-Account uses environment variable values to log into an Azure context. This is an internal function and
      should not be used outside of the BenchPress module.

    .DESCRIPTION
      Connect-Account is designed to login to an Azure context using environment variables to login as a
      ServicePrincipal for the PowerShell session.

      The expected environment variables are:
      AZ_USE_MANAGED_IDENTITY - If set to "true", BenchPress will login to Azure using a Managed Identity
      AZ_SUBSCRIPTION_ID - The Subscription ID to login to

      The following Environment variables are required if not using Managed Identity.
      AZ_APPLICATION_ID - The Service Principal ID
      AZ_ENCRYPTED_PASSWORD - The Service Principal account password properly encrypted using ConvertTo-SecureString
                              and saved as an environment variable using ConvertFrom-SecureString
      AZ_TENANT_ID - The Tenant ID to login to

      If the current context that is logged in to matches the Service Principal, Tenant, and Subscription this function
      is a no-op.

    .EXAMPLE
      There is only one way to call Connect-Account:

      Connect-Account

    .INPUTS
      None

    .OUTPUTS
      AuthenticationResult
  #>

  [OutputType([AuthenticationResult])]
  [CmdletBinding()]
  param ( )
  Begin { }
  Process {
    $useManagedIdentity = Get-EnvironmentVariable AZ_USE_MANAGED_IDENTITY -DontThrowIfMissing
    $subscriptionId = Get-EnvironmentVariable AZ_SUBSCRIPTION_ID
    $currentConnection = Get-AzContext
    $results = [AuthenticationResult]::new()

      # Login Using Managed Identity
    if ($useManagedIdentity) {
      $connection = Connect-AzAccount -Identity
      $subscriptionName = (Get-AzSubscription -SubscriptionId  $subscriptionId).Name
      Set-AzContext -Subscription $subscriptionName

      $results.Success = $true
      $results.AuthenticationData = [AuthenticationData]::new($connection.Context.Subscription.Id)
    } else {
      # If the current context matches the subscription, tenant, and service principal, then we're already properly
      # logged in.
      $applicationId = Get-EnvironmentVariable AZ_APPLICATION_ID
      $tenantId = Get-EnvironmentVariable AZ_TENANT_ID

      if (IsCurrentAccountLoggedIn($currentConnection)) {
        $results.Success = $true
        $results.AuthenticationData = [AuthenticationData]::new(($currentConnection).Subscription.Id)
      } else {
        # The current context is not correct
        # Create the credentials and login to the correct account

        $clientSecret = Get-EnvironmentVariable AZ_ENCRYPTED_PASSWORD | ConvertTo-SecureString
        $clientSecret = New-Object System.Management.Automation.PSCredential -ArgumentList $applicationId, $clientSecret

        try {
          $connectionParams = @{
            Credential   = $clientSecret
            TenantId     = $tenantId
            Subscription = $subscriptionId
          }
          $connection = Connect-AzAccount -ServicePrincipal @connectionParams

          $results.Success = $true
          $results.AuthenticationData = [AuthenticationData]::new($connection.Context.Subscription.Id)
        } catch {
          $thrownError = $_
          $results.Success = $false
          Write-Error $thrownError
        }
    }

  }

  $results

}
End { }


}

function IsCurrentAccountLoggedIn($currentConnection){
  if ($null -ne $currentConnection `
  -and ($currentConnection).Account.Type -eq 'ServicePrincipal' `
  -and ($currentConnection).Account.Id -eq $applicationId `
  -and ($currentConnection).Tenant.Id -eq $tenantId `
  -and ($currentConnection).Subscription.Id -eq $subscriptionId) {
    return $True
  }

  return $False
}
# file Modules/BenchPress.Azure/Private/Disconnect-Account.ps1

function Disconnect-Account {
  <#
    .SYNOPSIS
      Disconnect-Account uses environment variable values to disconnect from a specific Azure context. This is an
      internal function and should not be used outside of the BenchPress module.

    .DESCRIPTION
      Disconnect-Account is designed to automatically log out of the specific Azure context using environment variables
      to identify the context to disconnect.

      The expected environment variables are:

      AZ_APPLICATION_ID - The Service Principal ID
      AZ_TENANT_ID - The Tenant ID to login to
      AZ_SUBSCRIPTION_ID - The Subscription ID to login to

      If the current context does not match the Service Principal, Tenant, or Subscription then this function is a
      no-op.

    .EXAMPLE
      There is only one way to call Disconnect-Account:

      Disconnect-Account

    .INPUTS
      None

    .OUTPUTS
      None
  #>

  [OutputType([System.Void])]
  [CmdletBinding()]
  param ( )
  Begin {
    $applicationId = Get-EnvironmentVariable AZ_APPLICATION_ID
    $tenantId = Get-EnvironmentVariable AZ_TENANT_ID

    # If the current context doesn't match the target subscription, tentant, and client, then the testing account is
    # not logged in. Do nothing.
    $currentConnection = Get-AzContext
  }
  Process {
    if ($null -eq $currentConnection `
      -or ($currentConnection).Account.Type -ne "ServicePrincipal" `
      -or ($currentConnection).Account.Id -ne $applicationId `
      -or ($currentConnection).Tenant.Id -ne $tenantId) {
      return
    }

    $currentConnection | Disconnect-AzAccount -Scope CurrentUser
  }
  End { }
}
# file Modules/BenchPress.Azure/Private/Get-EnvironmentVariable.ps1
function Get-EnvironmentVariable {
  <#
    .SYNOPSIS
      Get-EnvironmentVariable is a private helper method that retrieves environment variables with the
      expectation that by default if they are not present that an error will be thrown.
      An override switch -DontThrowIfMissing can provided to skip throwing the exception.

    .DESCRIPTION
      Get-EnvironmentVariable retrieves the environment variable specified by the input parameter and checks to
      be sure that a value is present for that environment variable. If the value is missing or whitespace a error
      be be thrown unless the -DontThrowIfMissing switch is provided.

    .PARAMETER VariableName
      This is the name of the environment variable to retrieve and validate that a value is present.

    .PARAMETER DontThrowIfMissing
      This is a switch that can be provided to skip throwing an error if the environment variable is missing.

    .EXAMPLE
      Provide -VariableName Parameter.

      Get-RequiredEnvironmentVariable -VariableName AZ_APPLICATION_ID

    .EXAMPLE
      Provide variable name without -VariableName Parameter.

      Get-RequiredEnvironmentVariable AZ_APPLICATION_ID

    .EXAMPLE
      Provide -DontThrowIfMissing switch.

      Get-RequiredEnvironmentVariable -VariableName AZ_APPLICATION_ID -DontThrowIfMissing

    .INPUTS
      System.String

    .OUTPUTS
      System.String
  #>

  [OutputType([System.String])]
  param (
    [Parameter(Mandatory=$true, Position=0)]
    [string]$VariableName,
    [switch]$DontThrowIfMissing
  )
  Begin {
    $value = [string]$null
  }
  Process {
    $value = [System.Environment]::GetEnvironmentVariable($VariableName)

    if (-Not $DontThrowIfMissing -and [string]::IsNullOrWhiteSpace($value)) {
      throw "Missing Required Environment Variable $VariableName"
    }
  }
  End {
    $value
  }
}

function Get-RequiredEnvironmentVariable {
  [OutputType([System.String])]
  param (
    [Parameter(Mandatory=$true, Position=0)]
    [string]$VariableName
  )
  Begin {
    $value = [string]$null
  }
  Process {
    $value = Get-EnvironmentVariable $VariableName
  }
  End {
    $value
  }
}

Export-ModuleMember Confirm-ActionGroup,Confirm-AksCluster,Confirm-AksNodePool,Confirm-ApiManagement,Confirm-ApiManagementApi,Confirm-ApiManagementDiagnostic,Confirm-ApiManagementLogger,Confirm-ApiManagementPolicy,Confirm-AppInsights,Confirm-AppServicePlan,Confirm-BicepFile,Confirm-ContainerApp,Confirm-ContainerAppManagedEnv,Confirm-ContainerRegistry,Confirm-CosmosDBAccount,Confirm-CosmosDBGremlinDatabase,Confirm-CosmosDBMongoDBDatabase,Confirm-CosmosDBSqlDatabase,Confirm-CosmosDBSqlRoleAssignment,Confirm-CosmosDBSqlRoleDefinition,Confirm-DataFactory,Confirm-DataFactoryLinkedService,Confirm-DiagnosticSetting,Confirm-EventHub,Confirm-EventHubConsumerGroup,Confirm-EventHubNamespace,Confirm-KeyVault,Confirm-KeyVaultCertificate,Confirm-KeyVaultKey,Confirm-KeyVaultSecret,Confirm-OperationalInsightsWorkspace,Confirm-PortalDashboard,Confirm-PostgreSqlFlexibleServer,Confirm-Resource,Confirm-ResourceGroup,Confirm-RoleAssignment,Confirm-SqlDatabase,Confirm-SqlServer,Confirm-StorageAccount,Confirm-StorageContainer,Confirm-StreamAnalyticsCluster,Confirm-StreamAnalyticsFunction,Confirm-StreamAnalyticsInput,Confirm-StreamAnalyticsJob,Confirm-StreamAnalyticsOutput,Confirm-StreamAnalyticsTransformation,Confirm-SynapseSparkPool,Confirm-SynapseSqlPool,Confirm-SynapseWorkspace,Confirm-VirtualMachine,Confirm-WebApp,Confirm-WebAppStaticSite,Deploy-BicepFeature,Get-Resource,Get-ResourceByType,Invoke-AzCli,Remove-BicepFeature,BeInLocation,BeInResourceGroup,BeSuccessful