Skip to content
This repository was archived by the owner on May 5, 2023. It is now read-only.

Commit 4d219e2

Browse files
committed
merging autorest to master
1 parent fc9e09b commit 4d219e2

File tree

821 files changed

+217678
-72549
lines changed

Some content is hidden

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

821 files changed

+217678
-72549
lines changed

.gitignore

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
projects/*
22
targets/*
3+
packages/*
34

45
# Visual Studio #
56
*.suo
67
*.user
8+
.ntvs_analysis.dat
9+
obj/*
10+
examples/obj
11+
examples/.ntvs_analysis.dat
12+
examples/.vs
13+
examples/bin
14+
.vs
715

816
# Node #
9-
test/recordings/
1017
node_modules/
1118
npm-debug.log
1219
azure_error
@@ -33,6 +40,9 @@ docs/
3340
main.conf.json
3441
child.conf.json
3542

43+
# temporary test artifacts
44+
test/tmp/*
45+
3646
# Nuget packages and corresponding codegen sources
3747
.nuget
3848
packages

.npmignore

+3
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ gruntfile.js
4646
.nuget/
4747
packages/
4848
packages.config
49+
50+
# VS #
51+
.ntvs_analysis.*

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
language: node_js
2+
sudo: false
23
node_js:
4+
- "4.2"
35
- "0.12"
46
- "0.10"
5-
- "0.8"
67

78
matrix:
89
allow_failures:

Documentation/Authentication.md

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
2+
# Creating a ServicePrincipal for scripting scenarios
3+
One does not want to login interactively all the time. Azure provides service principal authentication as a secure way for silent login.
4+
5+
## Via Portal
6+
[This article](https://azure.microsoft.com/en-us/documentation/articles/resource-group-create-service-principal-portal/) provides detailed steps on creating a service principal via portal.
7+
8+
## Via XplatCLI
9+
Pre-requisite:
10+
- Install the latest version of cli from the [latest github release](https://github.com/Azure/azure-xplat-cli/releases) or from [npm](https://npmjs.com/package/azure-cli).
11+
12+
```bash
13+
npm uninstall azure-cli -g
14+
npm cache clear -g
15+
npm install azure-cli -g
16+
```
17+
- Login to the azure-cli via azure login command to create a service principal for future use.
18+
- For 2FA enabled user accounts `azure login`
19+
- For non 2FA enabled user accounts `azure login -u [email protected]`
20+
21+
After successful login, please follow the steps mentioned below to create a serviceprincipal:
22+
23+
#### Step 1. Create an aplication
24+
25+
Let us create an application with a password. The default start-date witll be the day of application creation and the default end-date will be 1 year from the day of creation.
26+
```
27+
D:\sdk>azure ad app create -n testap908 home-page http://www.bing.com --identifier-uris https://testap674.com/home -p P@ssw0rd
28+
info: Executing command ad app create
29+
+ Creating application testap674
30+
data: AppId: 56894bd4-0fde-41d8-a0d7-5bsslccety2
31+
data: ObjectId: g565675e8-7c30-908t-8548-87r98ew7rej
32+
data: DisplayName: testap674
33+
data: IdentifierUris: 0=https://testap674.com/home
34+
data: ReplyUrls:
35+
data: AvailableToOtherTenants: False
36+
data: AppPermissions:
37+
data: claimValue: user_impersonation
38+
data: description: Allow the application to access testap674 on behalf of the signed-in user.
39+
data: directAccessGrantTypes:
40+
data: displayName: Access testap674
41+
data: impersonationAccessGrantTypes: impersonated=User, impersonator=Application
42+
data: isDisabled:
43+
data: origin: Application
44+
data: permissionId: 12345698ui-fa71-4ab0-b647-fdajfhdakfh789
45+
data: resourceScopeType: Personal
46+
data: userConsentDescription: Allow the application to access testap674 on your behalf.
47+
data: userConsentDisplayName: Access testap674
48+
data: lang:
49+
info: ad app create command OK
50+
```
51+
52+
#### Step 2. Create a ServicePrincipal with the applicationId
53+
54+
Let us create a serviceprincipal using the applicationId from the previous step.
55+
```
56+
D:\sdk>azure ad sp create --aplicationId 56894bd4-0fde-41d8-a0d7-5bsslccety2
57+
info: Executing command ad sp create
58+
+ Creating service principal for application 56894bd4-0fde-41d8-a0d7-5bsslccety2
59+
data: Object Id: weewrerer-e329-4e9b-98c6-7878787
60+
data: Display Name: testap674
61+
data: Service Principal Names:
62+
data: 56894bd4-0fde-41d8-a0d7-5bsslccety2
63+
data: https://testap674.com/home
64+
info: ad sp create command OK
65+
```
66+
67+
#### Step 3. Assigning a role to a ServicePrincipal by using the spn
68+
69+
- You can get a list of available roles by ```azure role list```
70+
- In this example we are creating the serviceprincipal as a Contributor at the subscription level.
71+
- Definition of a Contributor
72+
```
73+
data: Name : Contributor
74+
data: Actions : 0=*
75+
data: NotActions : 0=Microsoft.Authorization/*/Delete, 1=Microsoft.Authorization/*/Write
76+
data: IsCustom : false
77+
```
78+
This will associate the serviceprincipal to your current subscription
79+
```
80+
D:\sdk>azure role assignment create --spn 56894bd4-0fde-41d8-a0d7-5bsslccety2 -o Contributor
81+
info: Executing command role assignment create
82+
+ Finding role with specified name
83+
/data: RoleAssignmentId : /subscriptions/abcdefgh-1234-4cc9-89b5-12345678/providers/Microsoft.Authorization/roleAssignments/987654-ea85-40a5-80c2-abcdferghtt
84+
data: RoleDefinitionName : Contributor
85+
data: RoleDefinitionId : jhfskjf-6180-42a0-ab88-5656eiu677e23e
86+
data: Scope : /subscriptions/abcdefgh-1234-4cc9-89b5-12345678
87+
data: Display Name : testap674
88+
data: SignInName :
89+
data: ObjectId : weewrerer-e329-4e9b-98c6-7878787
90+
data: ObjectType : ServicePrincipal
91+
data:
92+
+
93+
info: role assignment create command OK
94+
```
95+
96+
#### Step 4. Login as a serviceprincipal
97+
```
98+
D:\sdk>azure login -u 56894bd4-0fde-41d8-a0d7-5bsslccety2 -p P@ssw0rd --tenant <a guid OR your domain(contosocorp.com) --service-principal
99+
info: Executing command login
100+
\info: Added subscription TestSubscription
101+
+
102+
info: login command OK
103+
```
104+
105+
## Using serviceprincipal authentication in your node.js script
106+
```javascript
107+
var msrestAzure = require('ms-rest-azure');
108+
//service principal authentication
109+
'your-client-id' - is the spn ('56894bd4-0fde-41d8-a0d7-5bsslccety2')
110+
'your-domain' - is the tenant id (a guid) or the part **after @** in your username (user1@**contosocorp.com**) ('contosocorp.com')
111+
'your-secret' - is the password you created for the serviceprincipal ('P@ssw0rd')
112+
var credentials = new msRestAzure.ApplicationTokenCredentials('your-client-id', 'your-domain', 'your-secret');
113+
```
114+
115+
## Using user authentitcation in your node.js script
116+
Currently, the node sdk only supports users with org-id (organizational account) and have 2FA disabled.
117+
```javascript
118+
var msrestAzure = require('ms-rest-azure');
119+
//user authentication
120+
'your-client-id' - is the id provided by Azure Active Directory for your application
121+
'your-domain' - is the tenant id (a guid) or the part **after @** in your username (user1@**contosocorp.com**) ('contosocorp.com')
122+
'your-username' - is your username ('[email protected]')
123+
'your-password' - password associated with the username
124+
'your-redirect-uri' - is the redirect uri for your application. Providing 'http://localhost:8080' should also be fine.
125+
var credentials = new msRestAzure.UserTokenCredentials('your-client-id', 'your-domain', 'your-username', 'your-password', 'your-redirect-uri');
126+
```

Documentation/Debugging.md

+20-35
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,26 @@ console.log(">>>>>>>>>>>>>> Some Identifier " + util.inspect(some_object, {dep
1212
```
1313
Providing **{depth: null}** is optional. By default, it will dump object upto 3 levels deep. Setting depth to null will dump the complete object.
1414

15+
## Using Visual Studio
16+
The Visual Studio plugin for node.js can be downloaded from [here](https://github.com/Microsoft/nodejstools/releases).
17+
18+
### Setting up the project
19+
* Open the **nodeSDK.sln** file present at the root of the cloned repo.
20+
* Set the Tab size and Indentation to 2 spaces by going to
21+
* Tools --> Options --> TextEditor --> Node.js --> Tabs --> [Tab size: 2, Indent size: 2]
22+
* Tools --> Options --> TextEditor --> Javascript --> Tabs --> [Tab size: 2, Indent size: 2]
23+
24+
### For debugging the tests:
25+
* From the menu bar go to Project --> Properties and set the environment variables required for running tests.
26+
* The list of environment variables can be found over [here](./EnvironmentVariables.md)
27+
* If the need arises to add a new environment variable for tests please update the [Documentation](EnvironmentVariables.md) to keep the list current
28+
* Visual Studio can also be opened from **"Visual Studio Debugger Cmd Prompt"** usually located at "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts\Developer Command Prompt for VS2013.lnk" to set the environment variables. Then open the .sln file from the prompt.
29+
* In the Solution Explorer, click on a test that needs to be debugged. For example: "azure-sdk-for-node\test\services\storageManagement\storageManagementClient-tests.js"
30+
* In the **Properties** pane select **"Mocha"** as the Test Framework. Save All the changes.
31+
* The tests shall be seen in the "Test Explorer". Right Click on any Test and Select "Debug Selected Test".
32+
* **Note:** If the test file has any errors then you might not see the tests in the TestExplorer. In the Properties pane select **ExportRunner** as the test framework and save the solution. You will see the error in the output pane. Once the errors are resolved change the test framework back to **Mocha** in the Properties pane for that test file. When you save the solution, you should see your tests in the test explorer.
33+
* You can also run ```npm -s run-script jshint``` in the cmd prompt from the root of the repo to find errors if any.
34+
1535
## Using node inspector
1636
This will open a debugging session in a browser (chrome or opera). It is super easy to use.
1737
Steps to get it working:
@@ -52,38 +72,3 @@ Runner.prototype.runTest = function(fn){
5272
};
5373
```
5474
* Set a breakpoint in your test which should be located under "azure-sdk-for-node/test/commands" directory
55-
56-
57-
## Using Visual Studio
58-
The Visual Studio plugin for node.js can be downloaded from [here](http://nodejstools.codeplex.com/).
59-
60-
### Setting up the project
61-
* File --> New --> Project
62-
* On the left pane Installed --> Templates --> Javascript --> Node.js
63-
* From the available options Select "From Existing Node.js Code"
64-
* Provide a name to your project "xplat" and a name to the solution "xplat"
65-
* The location of the project would be the location of your cloned repo. Example - "D:\sdk\xplat\azure-sdk-tools-xplat"
66-
* Next --> Enter the filter to include files: In the end append the following string "; *._js"
67-
* Next --> Including node_modules in the project is optional. (It can always be include later, if the need arises).
68-
* Next --> Location for the project file - "D:\sdk\xplat\azure-sdk-tools-xplat\xplat.njsproj" --> Finish
69-
* In some time the solution explorer shows the source code files.
70-
* For better performance, it is advisable to **disable** intellisense in VisualStudio for Node.js projects by going to
71-
* Tools --> Options --> TextEditor --> Node.js --> Intellisense -->No Intellisense.
72-
* Set the Tab size and Indentation to 2 spaces by going to
73-
* Tools --> Options --> TextEditor --> Node.js --> Tabs --> [Tab size: 2, Indent size: 2]
74-
* Tools --> Options --> TextEditor --> Javascript --> Tabs --> [Tab size: 2, Indent size: 2]
75-
76-
### For debugging the service:
77-
* Create a sample.js file that instantiates the service client you intend to debug.
78-
* Right Click the "azure-sdk-for-node\sample.js" file and set it as Node.js startup file.
79-
* Set breakpoints at desired locations and Press F5 for happy debugging
80-
* At times, files with extension "._js" do not hit the breakpoint. It is flaky and nothing can be done about it. At such times, console.log() is your best buddy :+1:
81-
82-
### For debugging the tests:
83-
* From the menu bar go to Project --> Properties and set the environment variables required for running tests.
84-
* The list of environment variables can be found over [here](./EnvironmentVariables.md)
85-
* If the need arises to add a new environment variable for tests please update the [Documentation](EnvironmentVariables.md) to keep the list current
86-
* Visual Studio can also be opened from **"Visual Studio Debugger Cmd Prompt"** usually located at "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\Shortcuts\Developer Command Prompt for VS2013.lnk" to set the environment variables. Then open the .sln file from the prompt.
87-
* In the Solution Explorer, click on a test that needs to be debugged. For example: "azure-sdk-for-node\test\services\sql\sqlmanagementservice-tests.js"
88-
* In the **Properties** pane select **"Mocha"** as the Test Framework. Save All the changes.
89-
* The tests shall be seen in the "Test Explorer". Right Click on any Test and Select "Debug Selected Test".

Documentation/EnvironmentVariables.md

+29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
## Environment Variables Setup
22

3+
4+
### For clients targeting the ARM (V2) Azure API following environment variables need to be setup
5+
From an admin cmd console/terminal, at the root directory of your cloned repo, run the following for environment setup:
6+
* **Windows**
7+
```
8+
set AZURE_SUBSCRIPTION_ID=<A Guid>
9+
set CLIENT_ID=<A Guid> # Application Id provided by Azure Active Directory (SPN for service principal auth)
10+
set DOMAIN=<A Guid or the domain name of your org> contosoCorp.com
11+
set AZURE_USERNAME=<Your org-id user name> [email protected] # Only set this if you are using user authentication
12+
set AZURE_PASSWORD=<Your Password> # Only set this if you are using user authentication
13+
set APPLICATION_SECRET=<Your service principal password or secret> # Only set this if you are using service principal auth
14+
set NOCK_OFF=true
15+
set AZURE_NOCK_RECORD=
16+
```
17+
18+
* **OS X**, **Linux**
19+
```
20+
export AZURE_SUBSCRIPTION_ID=<A Guid>
21+
export CLIENT_ID=<A Guid> # Application Id provided by Azure Active Directory (SPN for service principal auth)
22+
export DOMAIN=<A Guid or the domain name of your org> contosoCorp.com
23+
export AZURE_USERNAME=<Your org-id user name> [email protected] # Only set this if you are using user authentication
24+
export AZURE_PASSWORD=<Your Password> # Only set this if you are using user authentication
25+
export APPLICATION_SECRET=<Your service principal password or secret> # Only set this if you are using service principal auth
26+
export NOCK_OFF=true
27+
export AZURE_NOCK_RECORD=
28+
```
29+
30+
### For clients targeting the ASM (V1) Azure API following environment variables need to be setup
31+
332
From an admin cmd console/terminal, at the root directory of your cloned repo, run the following for environment setup:
433
* **Windows**
534
```

Documentation/README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# Azure-SDK-For-Node Documentation
22

33
1. [Setting up the repo](./SetupRepo.md)
4+
2. [Login using ServicePrincipal](./Authentication.md)
5+
3. [Regenerating code for your service](./RegeneratingCode.md)
46
4. Testing the SDK
57
- [Setting up the Environment Variables](./EnvironmentVariables.md)
68
- [Test Modes & Recording Infrastructure](./TestModes.md)
79
- [Running Tests](./RunTests.md)
810
5. [Release Process](./ReleaseProcess.md)
9-
5. [Debugging the SDK](./Debugging.md)
10-
6. [Generating Self Signed Certificates for Testing Purpose](./DummyCerts.md)
11+
6. [Debugging the SDK](./Debugging.md)
12+
7. [Generating Self Signed Certificates for Testing Purpose](./DummyCerts.md)

Documentation/RegeneratingCode.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Regenerating Code
2+
3+
- Please execute `npm install` locally from the root of the cloned repo (This will install gulp locally for the repo).
4+
- Please install gulp globally `npm install gulp -g`
5+
- If you need the latest version of Autorest, then it needs to be specified in [gulpfile.js](https://github.com/Azure/azure-sdk-for-node/blob/autorest/gulpfile.js#L59)
6+
* Determining latest Autorest version
7+
* A beta version is published every night to a myget feed . Hence, set the autoRestVersion to yesterday's date. Always increment the version of Autorest by 1 from the publicly available version on [nuget](http://www.nuget.org/packages/AutoRest/). While this doc is being written the publicly available version is 0.14.0
8+
* ```var autoRestVersion=0.15.0-Nightly20160219```
9+
- Make sure you have updated the [mappings object](https://github.com/Azure/azure-sdk-for-node/blob/autorest/gulpfile.js#L6) correctly for generating the source code for your service
10+
- To list all the tasks execute `gulp -T` from the root of the repo
11+
- Regenertion command options
12+
- If you want to regenerate all the services then execute `gulp codegen`
13+
- If you want to generate for your project then execute `gulp codegen --project <your project name a.k.a the key of the mappings object>`
14+
- If you want to use a local file then save the file locally say "D:\sdk" and make sure to have the same path as defined in the source of your porject in the mappings object. Execute `gulp codegen --spec-root "D:\sdk" --project <your-project-name>`.
15+
- If generation is successful then you will see the generated code in the lib folder under `lib/services/<YourServiceName>`

Documentation/SetupRepo.md

-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ not polluted with your current changes.
1818
git checkout -b mybranch
1919
git push origin mybranch
2020
```
21-
* Setup the environment
22-
* On a Windows machine, open a cmd prompt as an Administrator and run the following command: ```npm run-script setup```
23-
* On a Mac or Linux machine, at the terminal run the following command: ```sudo npm run-script setup```
2421

2522
* Installing the required npm modules from the root directory```npm install```
2623

Documentation/TestModes.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,19 @@ The recordings will get saved in azure-xplat-cli/test/recordings/{test-suite} di
3131
#### Recording tests related to a specific service/feature
3232
If you plan on adding some tests / features and do not need to regenerate the full set of test recordings, you can open the file:
3333
```
34-
tests/testlist.txt (if you are writing tests for commands in asm mode)
35-
tests/testlistarm.txt (if you are writing tests for commands in arm mode)
34+
tests/testlist.txt (if you are writing tests for clients in asm mode)
35+
tests/testlistarm.txt (if you are writing tests for clients in arm mode)
3636
```
3737
and comment out the tests you do not wish to run during the recording process.
3838

3939
To do so, use a leading \# character. i.e.:
4040

41-
\# commands/cli.cloudservice-tests.js <br />
42-
\# commands/cli.deployment-tests.js <br />
43-
commands/cli.site-tests.js <br />
44-
\# commands/cli.site.appsetting-tests <br />
41+
\# services/resourceManagement/resourceManagementClient-tests.js <br />
42+
\# services/resourceManagement/authorizationClient-tests.js <br />
43+
services/storageManagement/storageManagementClient-tests.js <br />
44+
\# services/resourceManagement/featureClient-tests.js <br />
4545

46-
In the above example only the cli.site-tests.js tests would be run.
46+
In the above example only the storageManagementClient-tests.js tests would be run.
4747

4848
#### Recording a particular test in a suite
4949

0 commit comments

Comments
 (0)