Skip to content

Commit e1623df

Browse files
authored
Fix Azure Function capitalization (#108)
1 parent b1a4797 commit e1623df

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

Excel-custom-functions/AzureFunction/CustomFunctionProject/src/functions/functions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @returns {number} The sum of the two numbers.
77
*/
88
function add(first, second) {
9-
//If you publish the Azure function online, update the following URL to use the correct URL location.
9+
//If you publish the Azure Function online, update the following URL to use the correct URL location.
1010
let url = "http://localhost:7071/api/AddTwo";
1111

1212
return new Promise(function(resolve,reject){

Excel-custom-functions/AzureFunction/README.md

+30-30
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ extensions:
1111
technologies:
1212
- Add-ins
1313
createdDate: 10/2/2019 1:25:00 PM
14-
description: "You can expand the capabilities of Excel custom functions by integrating with Azure functions."
14+
description: "You can expand the capabilities of Excel custom functions by integrating with Azure Functions."
1515
---
1616

17-
# Integrate an Azure function with your Excel custom function
17+
# Integrate an Azure Function with your Excel custom function
1818

19-
You can expand the capabilities of Excel custom functions by integrating with Azure functions. An Azure function allows you to move your code to the cloud so it is not visible from the browser, and you can choose additional languages to run in besides JavaScript. Also an Azure function can integrate with other Azure services such as message queues and storage. And you can share the function with other clients.
19+
You can expand the capabilities of Excel custom functions by integrating with Azure Functions. An Azure Function allows you to move your code to the cloud so it is not visible from the browser, and you can choose additional languages to run in besides JavaScript. Also an Azure Function can integrate with other Azure services such as message queues and storage. And you can share the function with other clients.
2020

21-
This sample shows how to move the code from the `Add` custom function into an Azure function.
21+
This sample shows how to move the code from the `Add` custom function into an Azure Function.
2222

23-
![Overview diagram of Excel custom function calling an Azure function that returns a result.](images/azure-function-overview.png)
23+
![Overview diagram of Excel custom function calling an Azure Function that returns a result.](images/azure-function-overview.png)
2424

2525
## Applies to
2626

@@ -34,7 +34,7 @@ To set up your development environment:
3434
2. Install version 2.x of the [Azure Functions Core Tools](https://docs.microsoft.com/azure/azure-functions/functions-run-local#v2). Note: The sample does not use extension bundles so you will install the .NET Core 2.x SDK in a later step.
3535
3. Install the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp). You can also search for the C# extension in the VS Code Extensions view (Ctrl + Shift + X) and typing 'C# for Visual Studio Code'. Note: You will be notified to install the .NET Core 3.0 SDK, but this is not needed for this sample.
3636
4. Install the [Azure Functions extension](https://docs.microsoft.com/azure/azure-functions/functions-create-first-function-vs-code#install-the-azure-functions-extension). You can also search for the Azure Functions extension in the VS Code Extensions view (Ctrl + Shift + X) and typing 'Azure Functions'.
37-
5. Download and install [.NET Core 2.2](https://dotnet.microsoft.com/download/dotnet-core) which is the required version for Azure functions to build projects correctly.
37+
5. Download and install [.NET Core 2.2](https://dotnet.microsoft.com/download/dotnet-core) which is the required version for Azure Functions to build projects correctly.
3838

3939
You will also need the following:
4040

@@ -45,7 +45,7 @@ You will also need the following:
4545

4646
Solution | Author(s)
4747
---------|----------
48-
Azure function integration | David Chesnut (**Microsoft**)
48+
Azure Function integration | David Chesnut (**Microsoft**)
4949

5050
## Version history
5151

@@ -58,11 +58,11 @@ Version | Date | Comments
5858
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
5959

6060
----------
61-
## Try out the Azure function from localhost
61+
## Try out the Azure Function from localhost
6262

63-
This sample moves the `Add` custom function to an Azure function named `AddTwo()`. The Azure function adds the two numbers and returns the result. The next steps will run the sample. If you want to know how it works, jump down to the explanation section.
63+
This sample moves the `Add` custom function to an Azure Function named `AddTwo()`. The Azure Function adds the two numbers and returns the result. The next steps will run the sample. If you want to know how it works, jump down to the explanation section.
6464

65-
### Build and run the Azure function
65+
### Build and run the Azure Function
6666

6767
1. Clone or download this repository to a local project folder.
6868
2. Start Visual Studio Code and open the **AzureFunction/AzureFunctionProject** folder in the project.
@@ -72,11 +72,11 @@ This sample moves the `Add` custom function to an Azure function named `AddTwo()
7272
"command": "host start --cors https://localhost:3000",
7373
```
7474
This will modify the tasks so that when you run the project it opens port 3000 for CORS. This allows the Office Add-in to call the function in later steps since it will run on port 3000.
75-
5. From the **Debug** menu, choose **Start Debugging** (F5). The Azure function project will compile and start running.
75+
5. From the **Debug** menu, choose **Start Debugging** (F5). The Azure Function project will compile and start running.
7676
>Note: You may see an alert to allow func access through the firewall.
77-
After running you should see output similar to the following image. It will list the URL you can use to call the Azure function.
78-
![Screenshot of the Azure function project output window after debug start.](images/azure-debug-start.png)
79-
6. You can test that the Azure function is working by calling it from a browser. Open a browser window and enter the following URL to add two numbers.
77+
After running you should see output similar to the following image. It will list the URL you can use to call the Azure Function.
78+
![Screenshot of the Azure Function project output window after debug start.](images/azure-debug-start.png)
79+
6. You can test that the Azure Function is working by calling it from a browser. Open a browser window and enter the following URL to add two numbers.
8080
`http://localhost:7071/api/AddTwo?first=1&second=2`. You should see the result `{ "answer": 3}` returned to the browser.
8181

8282
### Build and run the custom function
@@ -101,12 +101,12 @@ This sample moves the `Add` custom function to an Azure function named `AddTwo()
101101
```command line
102102
$ npm run start:web
103103
```
104-
3. In Excel with the add-in loaded, try out the custom function by entering `=CONTOSO.ADD(1,2)` into a cell. The cell should call the custom function, which then calls the Azure function, and returns the result of 3.
104+
3. In Excel with the add-in loaded, try out the custom function by entering `=CONTOSO.ADD(1,2)` into a cell. The cell should call the custom function, which then calls the Azure Function, and returns the result of 3.
105105
![Screenshot of entering the value =CONTOSO.ADD(1,2) into a cell in Excel.](images/contoso-add-function.png)
106106

107107
## Deploy to an Azure Function App
108108

109-
You can also deploy and run the Azure function from your own Azure account.
109+
You can also deploy and run the Azure Function from your own Azure account.
110110

111111
1. Start Visual Studio Code and open the **AzureFunction/AzureFunctionProject** folder in the project.
112112
2. In Visual Studio Code, press F1 to open the command palette. In the command palette, search for and select **Azure Functions: Deploy to function app....** and then choose your subscription.
@@ -127,34 +127,34 @@ You can also deploy and run the Azure function from your own Azure account.
127127
7. Select the Azure icon on the Activity bar. You should see an Azure Functions area in the Side Bar.
128128
![Screenshot of the Azure icon on the Activity bar.](images/azure-icon.png)
129129
8. In the **Azure: Functions** area, expand the new function app under your subscription. Expand **Functions**, right-click **AddTwo**, and then choose **Copy function URL**.
130-
9. You can test that the Azure function is working by calling it from a browser. Open a browser window and enter the URL you just copied. If you want to add numbers, append the following query string to the URL `?first=1&second=2`. You should see the result `{ "answer": 3}` returned to the browser.
130+
9. You can test that the Azure Function is working by calling it from a browser. Open a browser window and enter the URL you just copied. If you want to add numbers, append the following query string to the URL `?first=1&second=2`. You should see the result `{ "answer": 3}` returned to the browser.
131131

132132
### Add CORS support for the custom function
133133

134-
You'll need to enable CORS support for the Office Add-in before it can call the Azure function online.
134+
You'll need to enable CORS support for the Office Add-in before it can call the Azure Function online.
135135

136-
1. Open the Azure portal and sign in. You can do this by selecting the Azure icon on the Activity bar in Visual Studio Code. Then right-click your Azure subscription for the Azure function and choose **Open in Portal**.
136+
1. Open the Azure portal and sign in. You can do this by selecting the Azure icon on the Activity bar in Visual Studio Code. Then right-click your Azure subscription for the Azure Function and choose **Open in Portal**.
137137
2. In the Azure portal, select the function app.
138138
3. Choose **Platform features**.
139139
4. Choose **CORS** in the **API** section.
140-
5. Add a new entry in the **Allowed Origins** list for `https://localhost:3000`. This will enable the custom function to call into the Azure function app.
140+
5. Add a new entry in the **Allowed Origins** list for `https://localhost:3000`. This will enable the custom function to call into the Azure Function app.
141141
6. Choose **Save**.
142142

143143
>**Note:** If you deploy the Excel custom function add-in, be sure to update the Allowed Origins list to support the new domain location.
144144

145-
## Update the Excel custom function to call into the Azure function app
145+
## Update the Excel custom function to call into the Azure Function app
146146

147-
Once the Azure function is deployed you can update the custom function to call the cloud version of the Azure function instead of the localhost version.
147+
Once the Azure Function is deployed you can update the custom function to call the cloud version of the Azure Function instead of the localhost version.
148148

149149
1. Start Visual Studio Code and open the **AzureFunction/CustomFunctionProject/src/functions/functions.js** file in the project.
150150
2. Go to the add function which sets the url string. The code appears as the following:
151151
```js
152152
function add(first, second) {
153-
//If you publish the Azure function online, update the following URL to use the correct URL location.
153+
//If you publish the Azure Function online, update the following URL to use the correct URL location.
154154
let url = "http://localhost:7071/api/AddTwo";
155155
...
156156
```
157-
3. In the `let url` assignment replace the localhost URL with the Azure function URL you copied from the previous exercise.
157+
3. In the `let url` assignment replace the localhost URL with the Azure Function URL you copied from the previous exercise.
158158
4. Run the following commands to build and start the custom function add-in on Excel on Windows. If the project was still running from a previous step, stop it and close Excel before restarting it.
159159
```command line
160160
$ npm run build
@@ -168,13 +168,13 @@ Once the Azure function is deployed you can update the custom function to call t
168168
$ npm run build
169169
$ npm run start:web
170170
```
171-
2. Try out the custom function by entering `=CONTOSO.ADD(1,2)` into a cell. The cell should call the custom function, which then calls the Azure function, and returns the result of 3.
171+
2. Try out the custom function by entering `=CONTOSO.ADD(1,2)` into a cell. The cell should call the custom function, which then calls the Azure Function, and returns the result of 3.
172172

173173
## Key parts of this sample
174174

175-
### The Azure function
175+
### The Azure Function
176176

177-
The Azure function is named `AddTwo()` and is in the **AzureFunctionProject/AddTow.cs** file. First the function needs to get the two parameters `first` and `second`. They might be passed as URL query parameters, or in a JSON body. So the code handles both scenarios. Notice the use of `??` and `?.` operators when retrieving values from the JSON body. It's possible a parameter was not passed and we don't want the code to fail because of a null. So these operators help work around any null parameters. For more information see [?? operator (C# reference)](https://docs.microsoft.com/dotnet/csharp/language-reference/operators/null-coalescing-operator) and [Null-conditional operators ?. and ?[]](https://docs.microsoft.com/dotnet/csharp/language-reference/operators/member-access-operators#null-conditional-operators--and-)
177+
The Azure Function is named `AddTwo()` and is in the **AzureFunctionProject/AddTow.cs** file. First the function needs to get the two parameters `first` and `second`. They might be passed as URL query parameters, or in a JSON body. So the code handles both scenarios. Notice the use of `??` and `?.` operators when retrieving values from the JSON body. It's possible a parameter was not passed and we don't want the code to fail because of a null. So these operators help work around any null parameters. For more information see [?? operator (C# reference)](https://docs.microsoft.com/dotnet/csharp/language-reference/operators/null-coalescing-operator) and [Null-conditional operators ?. and ?[]](https://docs.microsoft.com/dotnet/csharp/language-reference/operators/member-access-operators#null-conditional-operators--and-)
178178

179179
```csharp
180180
//retrieve parameters if passed on URL. They are passed in string format (convert them later)
@@ -207,11 +207,11 @@ return new OkObjectResult((n1+n2).ToString());
207207

208208
### The custom function
209209

210-
The Excel custom function is named `Add` and is in the **CustomFunctionProject/src/functions/functions.js** file. The `Add` function calls the `AddTwo` Azure function and just passes along the `first` and `second` parameters. The fetch function is used to call the Azure function, and the returned answer string is returned to Excel.
210+
The Excel custom function is named `Add` and is in the **CustomFunctionProject/src/functions/functions.js** file. The `Add` function calls the `AddTwo` Azure Function and just passes along the `first` and `second` parameters. The fetch function is used to call the Azure Function, and the returned answer string is returned to Excel.
211211

212212
```js
213213
function add(first, second) {
214-
//If you publish the Azure function online, update the following URL to use the correct URL location.
214+
//If you publish the Azure Function online, update the following URL to use the correct URL location.
215215
let url = "http://localhost:7071/api/AddTwo";
216216

217217
return new Promise(function(resolve,reject){
@@ -242,7 +242,7 @@ function add(first, second) {
242242

243243
### AzureFunctionProject notes
244244

245-
The Azure function is configured to allow anonymous access which means anyone can call the function if they have the URL. This is only for development purposes. In production code, you should configure [authentication and authorization in Azure App Service](https://docs.microsoft.com/azure/app-service/overview-authentication-authorization), to ensure only authorized users and code can call your Azure functions.
245+
The Azure Function is configured to allow anonymous access which means anyone can call the function if they have the URL. This is only for development purposes. In production code, you should configure [authentication and authorization in Azure App Service](https://docs.microsoft.com/azure/app-service/overview-authentication-authorization), to ensure only authorized users and code can call your Azure Functions.
246246

247247
### CustomFunctionProject notes
248248

0 commit comments

Comments
 (0)