Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync eng/common directory with azure-sdk-tools repository #13190

Merged
merged 1 commit into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The `eng/common` directory contains engineering files that are common across the
It should remain relatively small and only contain textual based files like scripts, configs, or templates. It
should not contain binary files as they don't play well with git.

# Updating
## Updating

Any updates to files in the `eng/common` directory should be made in the [azure-sdk-tools](https://github.com/azure/azure-sdk-tools) repo.
All changes made will cause a PR to created in all subscribed azure-sdk language repos which will blindly replace all contents of
Expand Down
45 changes: 35 additions & 10 deletions eng/common/TestResources/New-TestResources.ps1.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ schema: 2.0.0
# New-TestResources.ps1

## SYNOPSIS

Deploys live test resources defined for a service directory to Azure.

## SYNTAX

### Default (Default)
```

```text
New-TestResources.ps1 [-BaseName] <String> -ServiceDirectory <String> -TestApplicationId <String>
[-TestApplicationSecret <String>] [-TestApplicationOid <String>] [-DeleteAfterHours <Int32>]
[-Location <String>] [-Environment <String>] [-AdditionalParameters <Hashtable>] [-CI] [-Force] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### Provisioner
```

```text
New-TestResources.ps1 [-BaseName] <String> -ServiceDirectory <String> -TestApplicationId <String>
[-TestApplicationSecret <String>] [-TestApplicationOid <String>] -TenantId <String> [-SubscriptionId <String>]
-ProvisionerApplicationId <String> -ProvisionerApplicationSecret <String> [-DeleteAfterHours <Int32>]
Expand All @@ -30,7 +33,8 @@ New-TestResources.ps1 [-BaseName] <String> -ServiceDirectory <String> -TestAppli
```

## DESCRIPTION
Deploys live test resouces specified in test-resources.json files to a resource

Deploys live test resources specified in test-resources.json files to a resource
group.

This script searches the directory specified in $ServiceDirectory recursively
Expand All @@ -52,7 +56,8 @@ specified in $ProvisionerApplicationId and $ProvisionerApplicationSecret.
## EXAMPLES

### EXAMPLE 1
```

```text
Connect-AzAccount -Subscription "REPLACE_WITH_SUBSCRIPTION_ID"
$testAadApp = New-AzADServicePrincipal -Role Owner -DisplayName 'azure-sdk-live-test-app'
New-TestResources.ps1 `
Expand All @@ -69,7 +74,8 @@ Requires PowerShell 7 to use ConvertFrom-SecureString -AsPlainText or convert
the SecureString to plaintext by another means.

### EXAMPLE 2
```

```text
New-TestResources.ps1 `
-BaseName 'Generated' `
-ServiceDirectory '$(ServiceDirectory)' `
Expand All @@ -84,20 +90,21 @@ New-TestResources.ps1 `
-Verbose
```

Run this in an Azure DevOps CI (with approrpiate variables configured) before
Run this in an Azure DevOps CI (with appropriate variables configured) before
executing live tests.
The script will output variables as secrets (to enable
log redaction).

## PARAMETERS

### -BaseName

A name to use in the resource group and passed to the ARM template as 'baseName'.
Limit $BaseName to enough characters to be under limit plus prefixes specified in
the ARM template.
See also https://docs.microsoft.com/azure/architecture/best-practices/resource-naming

Note: The value specified for this parameter will be overriden and generated
Note: The value specified for this parameter will be overridden and generated
by New-TestResources.ps1 if $CI is specified.

```yaml
Expand All @@ -113,6 +120,7 @@ Accept wildcard characters: False
```

### -ServiceDirectory

A directory under 'sdk' in the repository root - optionally with subdirectories
specified - in which to discover ARM templates named 'test-resources.json'.
This can also be an absolute path or specify parent directories.
Expand All @@ -130,6 +138,7 @@ Accept wildcard characters: False
```

### -TestApplicationId

The AAD Application ID to authenticate the test runner against deployed
resources.
Passed to the ARM template as 'testApplicationId'.
Expand All @@ -150,6 +159,7 @@ Accept wildcard characters: False
```

### -TestApplicationSecret

Optional service principal secret (password) to authenticate the test runner
against deployed resources.
Passed to the ARM template as
Expand All @@ -171,6 +181,7 @@ Accept wildcard characters: False
```

### -TestApplicationOid

Service Principal Object ID of the AAD Test application.
This is used to assign
permissions to the AAD application so it can access tested features on the live
Expand All @@ -180,7 +191,7 @@ It is passed as to the ARM
template as 'testApplicationOid'

For more information on the relationship between AAD Applications and Service
Principals see: https://docs.microsoft.com/azure/active-directory/develop/app-objects-and-service-principals
Principals see: https://docs.microsoft.com/en-us/azure/active-directory/develop/app-objects-and-service-principals

```yaml
Type: String
Expand All @@ -195,6 +206,7 @@ Accept wildcard characters: False
```

### -TenantId

The tenant ID of a service principal when a provisioner is specified.
The same
Tenant ID is used for Test Application and Provisioner Application.
Expand All @@ -214,6 +226,7 @@ Accept wildcard characters: False
```

### -SubscriptionId

Optional subscription ID to use for new resources when logging in as a
provisioner.
You can also use Set-AzContext if not provisioning.
Expand All @@ -231,6 +244,7 @@ Accept wildcard characters: False
```

### -ProvisionerApplicationId

The AAD Application ID used to provision test resources when a provisioner is
specified.

Expand All @@ -251,6 +265,7 @@ Accept wildcard characters: False
```

### -ProvisionerApplicationSecret

A service principal secret (password) used to provision test resources when a
provisioner is specified.

Expand All @@ -271,6 +286,7 @@ Accept wildcard characters: False
```

### -DeleteAfterHours

Optional.
Positive integer number of hours from the current time to set the
'DeleteAfter' tag on the created resource group.
Expand All @@ -283,7 +299,7 @@ created resource group.
An optional cleanup process can delete resource groups whose "DeleteAfter"
timestamp is less than the current time.

This isused for CI automation.
This is used for CI automation.

```yaml
Type: Int32
Expand All @@ -298,6 +314,7 @@ Accept wildcard characters: False
```

### -Location

Optional location where resources should be created.
If left empty, the default
is based on the cloud to which the template is being deployed:
Expand All @@ -319,6 +336,7 @@ Accept wildcard characters: False
```

### -Environment

Name of the cloud environment.
The default is the Azure Public Cloud
('PublicCloud')
Expand All @@ -336,6 +354,7 @@ Accept wildcard characters: False
```

### -AdditionalParameters

Optional key-value pairs of parameters to pass to the ARM template(s).

```yaml
Expand All @@ -351,6 +370,7 @@ Accept wildcard characters: False
```

### -CI

Indicates the script is run as part of a Continuous Integration / Continuous
Deployment (CI/CD) build (only Azure Pipelines is currently supported).

Expand All @@ -367,6 +387,7 @@ Accept wildcard characters: False
```

### -Force

Force creation of resources instead of being prompted.

```yaml
Expand All @@ -382,6 +403,7 @@ Accept wildcard characters: False
```

### -WhatIf

Shows what would happen if the cmdlet runs.
The cmdlet is not run.

Expand All @@ -398,6 +420,7 @@ Accept wildcard characters: False
```

### -Confirm

Prompts you for confirmation before running the cmdlet.

```yaml
Expand All @@ -413,7 +436,8 @@ Accept wildcard characters: False
```

### -OutFile
save test environment settings into a test-resources.json.env file next to test-resources.json.

save test environment settings into a test-resources.json.env file next to test-resources.json.
The file is protected via DPAPI. The environment file would be scoped to the current repository directory.
Note: Supported only on Windows.

Expand All @@ -430,6 +454,7 @@ Accept wildcard characters: False
```

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS
Expand Down
8 changes: 4 additions & 4 deletions eng/common/TestResources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ eng\common\TestResources\New-TestResources.ps1 `
-TestApplicationSecret (ConvertFrom-SecureString $sp.Secret -AsPlainText)
```

If you are running this for a .NET project on Windows, the recommended method is to
add the `-OutFile` switch to the above command. This will save test environment settings
into a test-resources.json.env file next to test-resources.json. The file is protected via DPAPI.
The environment file would be scoped to the current repository directory and avoids the need to
If you are running this for a .NET project on Windows, the recommended method is to
add the `-OutFile` switch to the above command. This will save test environment settings
into a test-resources.json.env file next to test-resources.json. The file is protected via DPAPI.
The environment file would be scoped to the current repository directory and avoids the need to
set environment variables or restart your IDE to recognize them.

Along with some log messages, this will output environment variables based on
Expand Down
Loading