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
Copy file name to clipboardExpand all lines: clu-getstart.md
+60-35Lines changed: 60 additions & 35 deletions
Original file line number
Diff line number
Diff line change
@@ -2,10 +2,12 @@
2
2
3
3
### Prerequsites
4
4
5
-
Visual Studio 2015 RTM with ASP.NET. For details, check out the [installation doc](http://docs.asp.net/en/latest/getting-started/installing-on-windows.html).
5
+
*Visual Studio 2015 RTM with ASP.NET. For details, check out the [installation doc](http://docs.asp.net/en/latest/getting-started/installing-on-windows.html).
6
6
7
7
Note, after done, run `dnvm list` command to check the 'coreclr' runtime is installed with right version of `1.0.0-rc1-final`. If not, run `dnvm install 1.0.0-rc1-final -r coreclr -a x64 -p`. Remember always use `-p` flag, so the selection can persist.
8
8
9
+
* Get the latest dotnet from "https://azureclu.blob.core.windows.net/tools/dotnet-win-x64.latest.zip", unzip, then add its bin folder to the PATH
10
+
9
11
### Project Artifacts
10
12
11
13
CLUPackages require some additional files to direct generation of indexing, and to provide shortcuts when files are installed. These files can be copied from the Profile project and updated for each package.
@@ -23,7 +25,7 @@ CLUPackages require some additional files to direct generation of indexing, and
23
25
| ------------- |:-------------:|
24
26
| CommandAssemblies | File name of cmdlets assembly(ies) |
25
27
| NounPrefix | ‘AzureRm’ The part of the cmdlet noun to remove in clu commands|
26
-
| NounFirst | if true, the verb comes at the end of the command (e.g. azure resource get)|
28
+
| NounFirst | if true, the verb comes at the end of the command (e.g. az resource get)|
27
29
28
30
*\<modulename\>.nuspec.template, which contains nuspec format metadata about the package – the base temaplate is in tools\clu\Microsoft.Azure.Commands.nuspec.template. Here are the special fields defined in this template:
29
31
* %PackageId% - replace with the module name (Microsoft.Azure.Commands.\<rp-name\>)
@@ -50,35 +52,35 @@ CLUPackages require some additional files to direct generation of indexing, and
50
52
1. Run `<repo-root>\tools\CLU\BuildAndInstallClu.bat` which build and generate all cmdlet packages and deploy to under `<repo root>\drop\clurun` folder, with 3 flavors `win7-x64`, `osx.10.10-x64` and `ubuntu.14.04-x64`. When you have a clean environment or just pull from upstream, you should clean temporary bits such as `git clean -xdf`, and run this command.
51
53
2. Run `<repo-root>\tools\CLU\BuildCmdlet <package name like Microsoft.Azure.Commands.Profile>` <namelike:Microsoft.Azure.Commands.Profile>", this will build and refresh an individual cmdlet package.
52
54
53
-
After #1 above is finished, you can run `drop\clurun\<platform>\azure.bat help` to explore.
55
+
After #1 above is finished, you can run `drop\clurun\<platform>\az.bat help` to explore.
54
56
55
57
To debug, set environment variable of `DebugCLU` to "1". Then on running any command, you will be prompted to attach a debugger.
56
58
57
-
There is also `<repo-root>\tools\CLU\SetupEnv.bat` which is a windows batch wrapping around the `BuildAndInstallClu.bat`, plus set the `DebugCLU` for you, and add the `drop\clurun\win7-x64\azure.bat` to the PATH environment variable.
59
+
There is also `<repo-root>\tools\CLU\SetupEnv.bat` which is a windows batch wrapping around the `BuildAndInstallClu.bat`, plus set the `DebugCLU` for you, and add the `drop\clurun\win7-x64\az.bat` to the PATH environment variable.
58
60
59
-
To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, copy the flavor folder to your target machine, and run the "azure.sh" inside. Make sure set execution permission using `chmod +x azure.sh clurun`
61
+
To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, copy the flavor folder to your target machine, and run the "az.sh" inside. Make sure set execution permission using `chmod +x az.sh clurun`
60
62
61
63
(All of those are subject to change, contact yugangw or adxsdkdev for any questions)
62
64
63
65
### Quick introductions on cmdlets
64
-
* Run commands using the ‘azure’ prefix, cmdlet nouns, and cmdlet verbs, for example, `azure environment get` maps to the cmdlet `Get-AzureRmEnvironment`
65
-
* Cmdlet parameters use the double dash (--) so for example, getting a subscription with a particular name would be: `azure subscription get –-SubscriptionName “name of subscription"`
66
+
* Run commands using the ‘az’ prefix, cmdlet nouns, and cmdlet verbs, for example, `az env get` maps to the cmdlet `Get-AzureRmEnvironment`
67
+
* Cmdlet parameters use the double dash (--) so for example, getting a subscription with a particular name would be: `az subscription get –-SubscriptionName “name of subscription"`
66
68
* To log in, 3 options
67
-
* login interactively using device flow, this is the only option for msa account or any org-id with 2fa enforced, example: `azure account add`
68
-
* login with user and password, this works on org-id w/o 2fa enforced, example: `azure account add --Username [email protected] --Password password1`
69
-
* login as service principal. Example: `azure account add --ServicePrincipal --TenantId <tenant> --ApplicationId <id> --Secret <secret>`
69
+
* login interactively using device flow, this is the only option for msa account or any org-id with 2fa enforced, example: `az account add`
70
+
* login with user and password, this works on org-id w/o 2fa enforced, example: `az account add --Username [email protected] --Password password1`
71
+
* login as service principal. Example: `az account add --ServicePrincipal --TenantId <tenant> --ApplicationId <id> --Secret <secret>`
70
72
* Piping between cmdlets should work the same way that Powerhell piping works
71
-
```azure subscription get --SubscriptionName | azure context set```
73
+
```az subscription get --SubscriptionName | az context set```
72
74
* You can capture piped output using redirection to a file - the result will be the json serialization of the output object.
73
-
```azure subscription get > subscriptions.json```
74
-
* You can use file input tu aparameter using '@' notation:
75
-
```azure command --param1 @file1.json```
75
+
```az subscription get > subscriptions.json```
76
+
* You can use file input to a parameter using '@' notation:
77
+
```az command --param1 @file1.json```
76
78
Reads input from file1.json and attempts to deserialize the .net object that is the Parameter type for ```param1```
77
-
```azure command --param1 @@file1.json```
79
+
```az command --param1 @@file1.json```
78
80
Does the same thing, but treats the input from ```file1.json``` as if it come from the pipeline, so that multiple objects will result in multiple invocations of ```ProcessRecord()``` for the target cmdlet.
79
81
* There are some known issues with the current approach to sessions, which can cause session variables to not be propagated when running cmdlets in a pipeline, to work around this, set the 'CmdletSessionId' environment variable to a numeric value - all cmdlets running from the shell will use that session id, and sessions will work with pipelining
80
82
81
-
```set CmdletSessionId=1010 ```
83
+
```set AzureProfile=1010 ```
82
84
83
85
### Testing Cmdlets
84
86
@@ -92,12 +94,33 @@ Testing will consist of scenario tests and unit tests. Scenario tests should be
92
94
#### Scenario Tests
93
95
- Scenario tests should be saved under `./examples` directory with one directory per package. Each scenario tests should (eventually) consist of both `.ps1` and `.sh` files and should cover "P0" scenarios.
94
96
97
+
##### Environment Variables for Authentication
98
+
Please set the environment variables for either Username/Password (no 2FA) or ServicePrincipal authentication:
99
+
100
+
**Username/Password (without 2-factor auth):**
101
+
102
+
| Field (case sensitive) | Description |
103
+
| ------------- |:-------------|
104
+
| azureUser | an OrgId user name |
105
+
| password | a service principal name |
106
+
| userSubscription | (optional) Selects a particular subscription by id. If not provided, the first listed subscription will be selected |
107
+
108
+
**Service Principal:**
109
+
110
+
| Field (case sensitive) | Description |
111
+
| ------------- |:-------------|
112
+
| spn | The tenant guid to authenticate against |
113
+
| secret | the password or application secret to sue for authentication |
114
+
| tenant | The tenant guid to authenticate against |
115
+
| spnSubscription | (optional) Selects a particular subscription by id. If not provided, the first listed subscription will be selected |
116
+
95
117
##### XUnit Automation For Bash Scenario Tests
96
118
- The ```Commands.Common.ScenarioTest``` project contains classes that enable executing bash scenario tests in Visual Studio, or cross-platform using dnx.
97
119
98
120
- To implement an xunit bash scenario test you must
99
121
- Add a ```[Collection("SampleCollection")]``` attribute to your test class
100
-
- Add a field to your class of type ```ScenarioTestFixture``` and add a constructor that initializes it
122
+
- Add a field to your class of type ```ScenarioTestFixture``` and add a constructor that initializes it.
123
+
101
124
```C#
102
125
[Collection("SampleCollection")]
103
126
publicclassSampleTestClass
@@ -116,20 +139,22 @@ Testing will consist of scenario tests and unit tests. Scenario tests should be
- Set the environment variable 'TestCredentials' to a connection string providing the credentials to use during test execution. Possible fields include:
120
-
121
-
| Field (casesensitive) | Description |
122
-
| ------------- |:-------------|
123
-
| Username | an OrgId user name |
124
-
| ServicePrincipal | a service principal name |
125
-
| Password | the password or application secret to sue for authentication |
126
-
| TenantId | (required for Service authentication) The tenant guid to authenticate against |
127
-
| SubscriptionId | (optional) Selects a particular subscription by id. If not provided, the first listed subscription will be selected |
128
-
- The infrastructure automatically generates a resource group name and assigns the value to the bash variable ```"$resourceGroupName"```. If your scripts require additional variables, you can add these to your environment before running tests, or you can generate values using the ScriptRunner (for the tests using that runner).
142
+
- Set the [environmentvariables](#Environment_Variables_for_Authentication) for either Username/Password (no 2FA) orServicePrincipalauthentication
143
+
- UpdatePATHtoincludelocationofCLUbindrop.
144
+
```bash
145
+
exportPATH=/<path-to-drop>/clurun/win7-x64/:$PATH
146
+
```
147
+
- The infrastructure automatically generates the following environment variables:
148
+
- `BASEDIR` - directory path where test script is located
149
+
- `location` - default "WestUS" location
150
+
- `groupName` - randomly generated resource group name (note: the test guarantees that this resource group is deleted at the end of a test run; any other resource groups generated as part of the test run need to be deleted by the test)
151
+
- `storageAccountType` - default "Standard_GRS" storage account type
152
+
- `storageAccountName` - randomly generated storage account name
153
+
- If the script require additional variables, you can add these to your environment before running tests, or you can generate values using the ScriptRunner (for the tests using that runner).
- Tests can be executed in vs, or by runnign ```dnx test project.json```. If you execute dnx test from the project directory, it will work without modification and a log file for each script will be written to the test results directory ```..\TestResults```. If you execute dnx test from a different directory, you must set the following environment variables to provide the path to the examples directory and where to write log files:
157
+
- Tests can be executed in Visual Studio, or by running ```dnx test project.json```. If you execute dnx test from the project directory, it will work without modification and a log file for each script will be written to the test results directory ```..\TestResults```. If you execute dnx test from a different directory, you must set the following environment variables to provide the path to the examples directory and where to write log files:
133
158
134
159
| Environment Variable | Description |
135
160
| ------------- |:-------------|
@@ -138,14 +163,14 @@ Testing will consist of scenario tests and unit tests. Scenario tests should be
138
163
139
164
##### Running Bash Tests using Bash shell
140
165
- Bash tests should be runnable from bash shell in windows/linux/mac environments.
141
-
- To manually run the tests; please set the following envt. variables for authentication and run `./examples/lib/testrunner.sh`
166
+
- To manually run the tests; please set [environment variables](#Environment_Variables_for_Authentication) for authentication as well as update PATH and run `./examples/lib/testrunner.sh`
0 commit comments