зеркало из https://github.com/Azure/benchpress.git
This commit is contained in:
Родитель
1fa8249b03
Коммит
f7a81f00d3
|
@ -4,6 +4,7 @@
|
|||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
.env
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Import-Module $PSScriptRoot/Authentication.psm1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets an AKS Cluster.
|
||||
|
@ -30,6 +32,8 @@ function Get-AKSCluster {
|
|||
[string]$ResourceGroupName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
$resource = Get-AzAksCluster -ResourceGroupName $ResourceGroupName -Name $AKSName
|
||||
return $resource
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Import-Module $PSScriptRoot/Authentication.psm1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets an Action Group.
|
||||
|
@ -30,6 +32,8 @@ function Get-ActionGroup {
|
|||
[string]$ResourceGroupName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
$resource = Get-AzActionGroup -ResourceGroupName $ResourceGroupName -Name $ActionGroupName
|
||||
return $resource
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Import-Module $PSScriptRoot/Authentication.psm1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets an App Service Plan.
|
||||
|
@ -31,6 +33,8 @@ function Get-AppServicePlan {
|
|||
[string]$ResourceGroupName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
$resource = Get-AzAppServicePlan -ResourceGroupName $ResourceGroupName -Name $AppServicePlanName
|
||||
return $resource
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<#
|
||||
Import-Module $PSScriptRoot/Authentication.psm1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Confirm-AzBPBicepFile will confirm that the bicep files provided pass the checks executed by `bicep build`.
|
||||
|
||||
|
@ -159,6 +161,8 @@ function Deploy-BicepFeature(){
|
|||
$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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
Import-Module $PSScriptRoot/ActionGroup.psm1
|
||||
Import-Module $PSScriptRoot/AKSCluster.psm1
|
||||
Import-Module $PSScriptRoot/AppServicePlan.psm1
|
||||
Import-Module $PSScriptRoot/Authentication.psm1
|
||||
Import-Module $PSScriptRoot/ContainerRegistry.psm1
|
||||
Import-Module $PSScriptRoot/KeyVault.psm1
|
||||
Import-Module $PSScriptRoot/ResourceGroup.psm1
|
||||
|
@ -133,6 +134,8 @@ function Get-Resource {
|
|||
[string]$ResourceGroupName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
if ([string]::IsNullOrEmpty($ResourceGroupName)) {
|
||||
return Get-AzResource -Name "${ResourceName}"
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Import-Module $PSScriptRoot/Authentication.psm1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets a Container Registry.
|
||||
|
@ -31,6 +33,8 @@ function Get-ContainerRegistry {
|
|||
[string]$ResourceGroupName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
$resource = Get-AzContainerRegistry -ResourceGroupName $ResourceGroupName -Name $Name
|
||||
return $resource
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Import-Module $PSScriptRoot/Authentication.psm1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets a Key Vault.
|
||||
|
@ -31,6 +33,8 @@ function Get-KeyVault {
|
|||
[string]$ResourceGroupName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
$resource = Get-AzKeyVault -ResourceGroupName $ResourceGroupName -VaultName $Name
|
||||
return $resource
|
||||
}
|
||||
|
@ -105,6 +109,8 @@ function Get-KeyVaultSecret {
|
|||
[string]$KeyVaultName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
$resource = Get-AzKeyVaultSecret -Name $Name -VaultName $KeyVaultName
|
||||
return $resource
|
||||
}
|
||||
|
@ -179,6 +185,8 @@ function Get-KeyVaultKey {
|
|||
[string]$KeyVaultName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
$resource = Get-AzKeyVaultKey -Name $Name -VaultName $KeyVaultName
|
||||
return $resource
|
||||
}
|
||||
|
@ -253,6 +261,8 @@ function Get-KeyVaultCertificate {
|
|||
[string]$KeyVaultName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
$resource = Get-AzKeyVaultCertificate -Name $Name -VaultName $KeyVaultName
|
||||
return $resource
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Import-Module $PSScriptRoot/Authentication.psm1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets a Resource Group.
|
||||
|
@ -25,6 +27,8 @@ function Get-ResourceGroup {
|
|||
[string]$ResourceGroupName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
$resource = Get-AzResourceGroup $ResourceGroupName
|
||||
return $resource
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Import-Module $PSScriptRoot/Authentication.psm1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets one or more SQL Databases.
|
||||
|
@ -40,6 +42,8 @@ function Get-SqlDatabase {
|
|||
[string]$ResourceGroupName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
if ([string]::IsNullOrEmpty($databaseName)) {
|
||||
$resource = Get-AzSqlDatabase -ResourceGroupName $resourceGroupName -ServerName $serverName
|
||||
} else {
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Import-Module $PSScriptRoot/Authentication.psm1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets a SQL Server.
|
||||
|
@ -31,6 +33,8 @@ function Get-SqlServer {
|
|||
[string]$ResourceGroupName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
$resource = Get-AzSqlServer -ResourceGroupName $ResourceGroupName -ServerName $ServerName
|
||||
return $resource
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Import-Module $PSScriptRoot/Authentication.psm1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets a Virtual Machine.
|
||||
|
@ -31,6 +33,8 @@ function Get-VirtualMachine {
|
|||
[string]$ResourceGroupName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
$resource = Get-AzVM -ResourceGroupName $ResourceGroupName -Name $VirtualMachineName
|
||||
return $resource
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
Import-Module $PSScriptRoot/Authentication.psm1
|
||||
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets a Web App.
|
||||
|
@ -31,6 +33,8 @@ function Get-WebApp {
|
|||
[string]$ResourceGroupName
|
||||
)
|
||||
|
||||
Connect-Account
|
||||
|
||||
$resource = Get-AzWebApp -ResourceGroupName $ResourceGroupName -Name $WebAppName
|
||||
return $resource
|
||||
}
|
||||
|
|
|
@ -45,6 +45,20 @@ The easiest way to get started with BenchPress is to use the files in the `examp
|
|||
a String. `ConvertFrom-SecureString` will take the SecureString and convert it to an encrypted string. This value
|
||||
must then be saved as an environment variable. This ensures that the BenchPress code never uses the raw password at
|
||||
any point.
|
||||
|
||||
You can either use a `.env` file and pass in the environment variables locally with a script,
|
||||
or you must load each variable through the command line using:
|
||||
```PowerShell
|
||||
$Env:AZ_APPLICATION_ID="<sample-id>"
|
||||
$Env:AZ_TENANT_ID="<sample-id>"
|
||||
$Env:AZ_SUBSCRIPTION_ID="<sample-id>"
|
||||
$Env:AZ_ENCRYPTED_PASSWORD="<sample-id>"
|
||||
```
|
||||
|
||||
You can confirm if these are set up right on your local powershell using:
|
||||
```PowerShell
|
||||
[Environment]::GetEnvironmentVariables()
|
||||
```
|
||||
|
||||
## Running a test file
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ Describe 'Verify Resource Group Exists' {
|
|||
$rgName = "tflintrules"
|
||||
|
||||
#act
|
||||
$exists = Get-AzBPResourceGroupExists($rgName)
|
||||
$exists = Get-AzBPResourceGroupExist($rgName)
|
||||
|
||||
#assert
|
||||
$exists | Should -Be $true
|
||||
|
|
Загрузка…
Ссылка в новой задаче