You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. This starts VS Dev command prompt in PowerShell
26
+
1. This starts VS Dev command prompt in PowerShell in the azure-powershell/tools directory
19
27
2. Import module that helps in performing basic repository tasks
20
-
1. Import-Module Repo-Tasks.psd1
21
-
2. Type Get-Command -Module Repo-Tasks to see list of cmdlets
22
-
3. Get-Help <CommandName> to get help on individual commands.
28
+
1. Import-Module .\Repo-Tasks.psd1
23
29
24
-
## 2. Accquring TestFramework
30
+
## Acquiring TestFramework
25
31
26
32
TestFramework is available on NuGet at https://www.nuget.org/packages/Microsoft.Rest.ClientRuntime.Azure.TestFramework/ .
27
33
28
34
Instructions to manually download it are available on NuGet. However TestFramework will be downloaded automatically as part of the build process, so manually downloading it should generally be unnecessary.
29
35
30
-
## 3. Setup prior to Record/Playback of tests
36
+
## Setup prior to Record or Playback of tests
31
37
32
-
In order to Record/Playback a test, you need to setup a connection string that consists various key/value pairs that provides information to the test environment.
38
+
In order to Record/Playback a test, you need to setup a connection string that consists of various key/value pairs that provides information to the test environment. You have three options to set up the connection string: run the [New-TestCredential cmdlet](#new-testcredential) (recommended), run the [Set-TestEnvironment cmdlet](#set-testenvironment), or [manually set the environment variables](#manually-set-environment-variables).
33
39
34
-
#### 3.1 Environment Variables
40
+
### New-TestCredential
41
+
42
+
This cmdlet, located in Repo-Tasks, will allow you to create a credentials file (located in C:/Users/\<currentuser\>/.azure/testcredentials.json) that will be used to set the environment variable when scenario tests are run. This credentials file will be used in all future sessions unless it is deleted or the environment variables are manually set.
43
+
44
+
#### Create New Service Principal
45
+
46
+
Using a Service Principal is the preferred option for recording tests because it works with both .NET Framework and .NET Core. In order to create a new Service Principal run this command with a unused ServicePrincipal display name:
This command will create a new Service Principal, set the correct role assignment for this Service Principal based upon the subscription provided, and place the Service Principal id and secret into the credentials file.
54
+
55
+
#### Use Existing Service Principal
56
+
57
+
If you would like to use an existing Service Principal, run this command with an existing ServicePrincipal display name and secret:
58
+
59
+
```powershell
60
+
New-TestCredential -ServicePrincipalDisplayName "Existing Service Principal" -ServicePrincipalSecret `
This is no longer the preferred option because it only works when running on .NET Framework. When running on .NET Core you may get an error like `Interactive Login is supported only in NET45 projects`. Additionally, you will have to manually log in when running the scenario tests rather than being automatically validated.
This is no longer the preferred option because it only works when running on .NET Framework. When running on .NET Core you may get an error like `Interactive Login is supported only in NET45 projects`.
@@ -41,14 +104,14 @@ This is the connection string that determined how to connect to Azure. This incl
41
104
42
105
This specifies whether test framework will `Record` test sessions or `Playback` previously recorded test sessions.
43
106
44
-
#### 3.2 Playback Test
107
+
#### Playback Test
45
108
46
109
The default mode is Playback mode, so no setting up of connection string is required. You can optionally set environment variables:
47
110
48
111
TEST_CSM_ORGID_AUTHENTICATION=
49
112
AZURE_TEST_MODE=Playback
50
113
51
-
#### 3.3 Record Test with Interactive login using OrgId
114
+
#### Record Test with Interactive login using OrgId
52
115
53
116
This is no longer the preferred option because it only works when running on .NET Framework. When running on .NET Core you may get an error like `Interactive Login is supported only in NET45 projects`.
54
117
@@ -57,9 +120,9 @@ To use this option, set the following environment variables before starting Visu
This is the preferred option for record because it works with both .NET Framework and .NET Core.
125
+
This is the preferred option for recording tests because it works with both .NET Framework and .NET Core.
63
126
64
127
To create a service principal, follow the [Azure AD guide to create a Application Service Principal](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#create-an-active-directory-application). The application type should be `Web app / API` and the sign-on URL value is irrelevant (you can set any value).
65
128
@@ -79,14 +142,14 @@ To use this option, set the following environment variable before starting Visua
1. Run the test and make sure that you got a generated .json file that matches the test name in the bin folder under *SessionRecords folder
85
148
2. Copy SessionRecords folder inside the test project and add all *.json files in Visual Studio setting "Copy to Output Directory" property to "Copy if newer"
86
149
3. To assure that the records work fine, delete the connection string (default mode is Playback mode) OR change HttpRecorderMode within the connection string to "Playback"
87
150
88
-
## 5. Change Test Environment settings at run-time
89
-
#### 1. Once you set your connection string, you can add or update key/value settings
151
+
## Change Test Environment settings at run-time
152
+
#### Once you set your connection string, you can add or update key/value settings
@@ -100,7 +163,7 @@ To use this option, set the following environment variable before starting Visua
100
163
###Note:###
101
164
Changing the above properties at run-time has the potential to hard code few things in your tests. Best practice would be to use these properties to change values at run-time from immediate window at run-time and avoid hard-coding certain values.
102
165
103
-
## 6. Troubleshooting
166
+
## Troubleshooting
104
167
105
168
#### Issue: exceptions in Microsoft.Azure.Test.HttpRecorder
106
169
@@ -112,7 +175,7 @@ In order to debug test set the following environment variables before starting V
0 commit comments