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: readme.md
+29-21Lines changed: 29 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -36,10 +36,13 @@ In this lab, you will learn how to:
36
36
![Screen shot 003 - Select a type of function][3]
37
37
38
38
7. After the Function is created you get to see a dashboard with some code and a couple of buttons. Just press **Run** and see what happens.
39
+
39
40
8. In the right bottom corner you can see the output result. Obviously you can change the *name* request property in the request body and press *Run* in the bottom right corner to see the changes.
40
41
![Screen shote 004 - HTTP Result][4]
42
+
41
43
9. Now we have a functional 'API' so to speak. We need an URL to send requests to. In the top right corner there is small link **'</> Get function URL'** Click this link to gain the URL.
42
44
![Screen shot 005 - API URL][5]
45
+
43
46
10. You can test this URL by just plain pasting it into the browser and run it. Additionally you can append a 'name' property into the querystring to test the response.
44
47
![Screen shot 006 - HTTP Response][6]
45
48
@@ -54,58 +57,60 @@ In this lab, you will learn how to:
54
57
<aname="create-from-cli"></a>
55
58
## Create a function from the Command Line Interface (CLI)
56
59
57
-
At this moment the *Azure Functions* option (which is available from the Azure SDK) is not yet supported for Visual Studio 2017. The Microsoft Azure team is working hard to get it live but while I'm writing this Lab there is still no release date available. Source: [GitHub Azure](https://github.com/Azure/Azure-Functions/issues/201)
58
-
The version for Visual Studio 2015 that IS available is not always working as expected. Actually I couldn't get it to work at all.
59
-
Luckily there is a way to create a local Azure Function via the Command Line Interface (CLI).
60
60
In this Lab we will create the same Azure Function as before but we don't create it in the cloud via a fancy portal. We want to create it locally before sending it to Azure.
61
61
This is convenient because this way we can develop and test the function without any Azure costs (as we are using our localhost IIS as 'provider')
62
62
63
63
1. First of, make sure you have Node Package Manager (NPM) installed. See [npmjs.org/get-npm](https://www.npmjs.com/get-npm) for more information.
64
-
2. Next, open the command prompt (you can use the nodejs command prompt or the default DOS prompt) and install the *azure-functions-cli* package globally:
64
+
65
+
2. Next, open the command prompt as administrator (you can use the nodejs command prompt or the default DOS prompt) navigate to a desired empty folder and install the *azure-functions-core-tools* package globally:
65
66
```code
66
-
npm install -g azure-functions-cli
67
+
npm install -g azure-functions-core-tools
67
68
```
68
69
69
-
Which results in npm downloading and installing the Azure Functions CLI package into the current directory.
70
+
Which results in npm downloading and installing the _Azure Functions CLI_ package into the current directory.
70
71
![Screenshot 007 install Azure Functions CLI via NPM][7]
71
72
72
73
3. Meanwhile create a new folder on a location where you desire to create a new local Azure Function.
74
+
73
75
4. When the installation is done navigate via the prompt to the directory you just created.
76
+
74
77
5. Run *func* as a command to the see possible options.
75
78
![Screenshot 008 Create a new Azure Function via the CLI][8]
76
79
77
80
6. We want to create a new Azure Function so let's run the following commmand:
78
81
```code
79
82
func new
80
83
```
84
+
81
85
7. It will return a list of language options. Use the **UP** and **DOWN** key to scroll trough the possible options and select **C#** by pressing *Enter*.
82
-
![Screenshot 009 A new function based on C#][9]
86
+
87
+
![Screenshot 009 A new function based on C#][9]
83
88
84
89
> Tip: Hit CTRL+C to abort the current execution (for instance when you picked the wrong template)
85
90
86
91
8. Next select the **HttpTrigger** option from the template list.
87
92
9. Finally type a name of your Azure Function and press enter to start the creation of the Function. Please be aware that the name you enter here will be created as a folder so try to prevent spaces and other non-folderish-names and keep it short.
88
93
![Screenshot 010 Naming the Azure function][10]
89
94
90
-
>```<nerd-modus>```
91
-
>
92
-
> You can also go complete rogue and type the whole command at once by using the following parameters:
93
-
>
94
-
> ```func new -l C# -t HttpTrigger -n AzureBootcampLocal```
95
-
>
96
-
>```</nerd-modus>```
95
+
\
96
+
```<nerd-modus>```
97
+
98
+
You can also go rogue and type the whole command at once by using the following parameters:
97
99
98
-
![Screenshot 011 Be that nerd!][11]
100
+
> func new -l C# -t HttpTrigger -n AzureBootcampLocal
101
+
![Screenshot 011 Be that nerd!][11]
102
+
103
+
```</nerd-modus>```
99
104
100
105
101
106
10. Now when you check out the directory you can see that a new folder was created, with the name you've just entered and a foursome of files. You can open run.csx and check out the code. That might look a bit familiar. That's because it's the same default template as we created in the online portal.
102
-
11. Tryin to run this Azure Function with ```func run AzureBootcampLocal``` followed by an extra enter (confirming the launch of a new server) leads to an unforgiving and not-so-very-explanatory exception: **An error occurred while sending the request**
107
+
11. Tryin to run this Azure Function with ```func run AzureBootcampLocal``` followed by an extra enter (confirming the launch of a new server) leads to an unforgiving and not-so-very-explanatory exception: **Unable to find function project root. Expecting to have host.json in function project root.**
103
108
![Screenshot 012 Wut?!][12]
104
109
105
-
12. Before you can run the function you need to initialize it first. You can do so by running the next command: ```func init``` (nb. without the name of the project)
106
-
> Tip: Running ```func init AzureBootcampLocal``` will not work. The files end up in the wrong folder and the server wont start giving you the same exception as earlier 'An error occurred while sending the request'.
110
+
12. Before you can run the function you need to initialize it first. You can do so by running the next command: ```func init```
111
+
107
112
108
-
13. After that you can run ```func run AzureBootcampLocal``` again to start up the local server and run your Function. This will open a new Command window showing the host information like below:
113
+
13. After that you can run ```func run AzureBootcampLocal``` again to start up the local server and run your Function. Hit enter when the question appears of always showing a warning. This will open a new Command window showing the host information like below:
109
114
110
115
![Screenshot 013 Localhost][13]
111
116
@@ -120,9 +125,11 @@ This will show up a page confirming that the server is operating and the functio
120
125
16. So append the requested parameter to the URI string and run request again.
121
126
![Screenshot 016 Localhost][16]
122
127
123
-
> You can also use Postman instead of your browser but I just wanted to show the working function.
128
+
> You can also use Postman instead of your browser.
129
+
![Screenshot 017 Request via Postman][17]
130
+
124
131
125
-
17. There you have it (again), A fully functional Azure Function but local so you can test it first.
132
+
17. There you have it (again), A fully functional Azure Function, but local so you can test it first.
126
133
127
134
128
135
@@ -147,3 +154,4 @@ For more information, please check out [functions.azure.com](https://functions.a
0 commit comments