Skip to content

Commit ab46933

Browse files
author
Anavi Nahar
committed
Update for Set-AzureRmNetworkInterface cmdlet examples
2 parents 70bfff5 + 6980f5b commit ab46933

File tree

295 files changed

+35160
-20381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

295 files changed

+35160
-20381
lines changed

appveyor.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ build_script:
4242
{
4343
continue
4444
}
45-
robocopy $help "*.md" (Join-Path $global:output $folder | Join-Path -ChildPath (gi $psd1).BaseName | Join-Path -ChildPath ("v" + ($matches[0] -match $pattern)))
45+
if($matches[0] -match $pattern)
46+
{
47+
robocopy $help "*.md" (Join-Path $global:output $folder | Join-Path -ChildPath (gi $psd1).BaseName | Join-Path -ChildPath ("v" + $matches[0]))
48+
}
4649
}
4750
}
4851
test: off

documentation/Using-Azure-TestFramework.md

Lines changed: 76 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
2. Accquring TestFramework
55
3. Setup prior to Record/Playback tests
66
1. Environment Variables
7-
2. Connection string
8-
3. Defaults
7+
2. Playback Test
8+
3. Record Test with Interactive login using OrgId
9+
4. Record Test with ServicePrincipal
910
4. Record/Playback tests
10-
1. Playback Tests
11-
2. Record tests using interactive login (using orgId)
12-
3. Record tests using Service Principal
1311
5. Change Test Environment settings at run-time
14-
12+
6. Troubleshooting
13+
7. Environment Variable Reference
1514

1615
## 1. Getting Started
1716
1. Launch .\tools\PS-VSPrompt shortcut
@@ -28,6 +27,7 @@ TestFramework is available on NuGet at https://www.nuget.org/packages/Microsoft.
2827
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.
2928

3029
## 3. Setup prior to Record/Playback of tests
30+
3131
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.
3232

3333
#### 3.1 Environment Variables
@@ -40,7 +40,74 @@ This is the connection string that determined how to connect to Azure. This incl
4040
4141
This specifies whether test framework will `Record` test sessions or `Playback` previously recorded test sessions.
4242

43-
#### 3.2. Supported Keys in connection string
43+
#### 3.2 Playback Test
44+
45+
The default mode is Playback mode, so no setting up of connection string is required. You can optionally set environment variables:
46+
47+
TEST_CSM_ORGID_AUTHENTICATION=
48+
AZURE_TEST_MODE=Playback
49+
50+
#### 3.3 Record Test with Interactive login using OrgId
51+
52+
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`.
53+
54+
To use this option, set the following environment variables before starting Visual Studio:
55+
56+
TEST_CSM_ORGID_AUTHENTICATION=SubscriptionId={SubId};UserId={orgId};AADTenant={tenantId};Environment={env};HttpRecorderMode=Record;
57+
AZURE_TEST_MODE=Record
58+
59+
#### 3.4 Record Test with ServicePrincipal
60+
61+
This is the preferred option for record because it works with both .NET Framework and .NET Core.
62+
63+
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).
64+
65+
After the service principal is created, you will need to give it access to Azure resources. This can be done with the following PowerShell command, with the [Service Principal Application ID](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-application-id-and-authentication-key) (this is a guid, not the display name of the service principal) substituted in for `{clientId}`.
66+
67+
New-AzureRmRoleAssignment -ServicePrincipalName {clientId} -RoleDefinitionName Contributor
68+
69+
To use this option, set the following environment variable before starting Visual Studio. The following values are substituted into the below connection string:
70+
71+
`clientId`: The [Service Principal Application ID](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-application-id-and-authentication-key)
72+
73+
`clientSecret`: A [Service Principal Authentication Key](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-application-id-and-authentication-key)
74+
75+
`tenantId`: The [AAD Tenant ID](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-tenant-id)
76+
77+
78+
TEST_CSM_ORGID_AUTHENTICATION=SubscriptionId={SubId};ServicePrincipal={clientId};ServicePrincipalSecret={clientSecret};AADTenant={tenantId};Environment={env};HttpRecorderMode=Record;
79+
AZURE_TEST_MODE=Record
80+
81+
## 4. Record/Playback Tests
82+
83+
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
84+
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"
85+
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"
86+
87+
## 5. Change Test Environment settings at run-time
88+
#### 1. Once you set your connection string, you can add or update key/value settings
89+
90+
Add new key/value pair
91+
TestEnvironment.ConnectionString.KeyValuePairs.Add("Foo", "FooValue");
92+
93+
Update Existing key/value pair
94+
TestEnvironment.ConnectionString.KeyValuePairs["keyName"]="new value"
95+
96+
Accessing/Updating TestEndpoints
97+
TestEnvironment.Endpoints.GraphUri = new Uri("https://newGraphUri.windows.net");
98+
99+
###Note:###
100+
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.
101+
102+
## 6. Troubleshooting
103+
104+
#### Issue: exceptions in Microsoft.Azure.Test.HttpRecorder
105+
106+
Ensure that the `HttpRecorderMode` in the `TEST_CSM_ORGID_AUTHENTICATION` environment variable is consistent with the value in `AZURE_TEST_MODE` environment variable.
107+
108+
## 7. Environment Variable Reference
109+
110+
#### 7.1. Supported Keys in connection string
44111
* ManagementCertificate
45112
* SubscriptionId
46113
* AADTenant
@@ -62,7 +129,8 @@ This specifies whether test framework will `Record` test sessions or `Playback`
62129
* AADAuthEndpoint
63130
* GraphTokenAudienceUri
64131

65-
#### 3.3. Environment Defaults
132+
133+
#### 7.2 Environment Defaults
66134

67135
Setting `Environment` in the connection string will result in the following default values:
68136

@@ -121,58 +189,3 @@ Setting `Environment` in the connection string will result in the following defa
121189
GraphTokenAudienceUri = "https://graph.ppe.windows.net/"
122190
DataLakeStoreServiceUri = "https://caboaccountdogfood.net"
123191
DataLakeAnalyticsJoAbndCatalogServiceUri = "https://konaaccountdogfood.net"
124-
125-
## 4. Record/Playback Test
126-
127-
#### Playback Test
128-
129-
The default mode is Playback mode, so no setting up of connection string is required.
130-
131-
#### Record Test with Interactive login using OrgId
132-
133-
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`.
134-
135-
To use this option, set the following environment variable before starting Visual Studio:
136-
137-
TEST_CSM_ORGID_AUTHENTICATION=SubscriptionId={SubId};UserId={orgId};AADTenant={tenantId};Environment={env};HttpRecorderMode=Record;
138-
139-
#### Record Test with ServicePrincipal
140-
141-
This is the preferred option because it works with both .NET Framework and .NET Core.
142-
143-
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).
144-
145-
After the service principal is created, you will need to give it access to Azure resources. This can be done with the following PowerShell command, with the [Service Principal Application ID](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-application-id-and-authentication-key) (this is a guid, not the display name of the service principal) substituted in for `{clientId}`.
146-
147-
New-AzureRmRoleAssignment -ServicePrincipalName {clientId} -RoleDefinitionName Contributor
148-
149-
To use this option, set the following environment variable before starting Visual Studio. The following values are substituted into the below connection string:
150-
151-
`clientId`: The [Service Principal Application ID](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-application-id-and-authentication-key)
152-
153-
`clientSecret`: A [Service Principal Authentication Key](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-application-id-and-authentication-key)
154-
155-
`tenantId`: The [AAD Tenant ID](https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal#get-tenant-id)
156-
157-
158-
TEST_CSM_ORGID_AUTHENTICATION=SubscriptionId={SubId};ServicePrincipal={clientId};ServicePrincipalSecret={clientSecret};AADTenant={tenantId};Environment={env};HttpRecorderMode=Record;
159-
160-
161-
2. 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
162-
3. 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"
163-
4. 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"
164-
165-
## 5. Change Test Environment settings at run-time
166-
#### 1. Once you set your connection string, you can add or update key/value settings
167-
168-
Add new key/value pair
169-
TestEnvironment.ConnectionString.KeyValuePairs.Add("Foo", "FooValue");
170-
171-
Update Existing key/value pair
172-
TestEnvironment.ConnectionString.KeyValuePairs["keyName"]="new value"
173-
174-
Accessing/Updating TestEndpoints
175-
TestEnvironment.Endpoints.GraphUri = new Uri("https://newGraphUri.windows.net");
176-
177-
###Note:###
178-
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.

0 commit comments

Comments
 (0)