Skip to content

Commit 82cbe4f

Browse files
Merge pull request #226787 from JialinXin/patch-16
[WebPubSub] Fix index path
2 parents 852e5a8 + 3155cae commit 82cbe4f

File tree

2 files changed

+6
-22
lines changed

2 files changed

+6
-22
lines changed

articles/azure-web-pubsub/quickstart-serverless.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,7 @@ In this tutorial, you learn how to:
118118
var path = require('path');
119119
120120
module.exports = function (context, req) {
121-
var index = 'index.html';
122-
if (process.env["HOME"] != null)
123-
{
124-
index = path.join(process.env["HOME"], "site", "wwwroot", index);
125-
}
121+
var index = context.executionContext.functionDirectory + '/../index.html';
126122
context.log("index.html path: " + index);
127123
fs.readFile(index, 'utf8', function (err, data) {
128124
if (err) {
@@ -145,13 +141,9 @@ In this tutorial, you learn how to:
145141
- Update `index.cs` and replace `Run` function with following codes.
146142
```c#
147143
[FunctionName("index")]
148-
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous)] HttpRequest req, ILogger log)
144+
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous)] HttpRequest req, ExecutionContext context, ILogger log)
149145
{
150-
string indexFile = "index.html";
151-
if (Environment.GetEnvironmentVariable("HOME") != null)
152-
{
153-
indexFile = Path.Join(Environment.GetEnvironmentVariable("HOME"), "site", "wwwroot", indexFile);
154-
}
146+
var indexFile = Path.Combine(context.FunctionAppDirectory, "index.html");
155147
log.LogInformation($"index.html path: {indexFile}.");
156148
return new ContentResult
157149
{

articles/azure-web-pubsub/tutorial-serverless-notification.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,7 @@ In this tutorial, you learn how to:
141141
var path = require('path');
142142
143143
module.exports = function (context, req) {
144-
var index = 'index.html';
145-
if (process.env["HOME"] != null)
146-
{
147-
index = path.join(process.env["HOME"], "site", "wwwroot", index);
148-
}
144+
var index = context.executionContext.functionDirectory + '/../index.html';
149145
context.log("index.html path: " + index);
150146
fs.readFile(index, 'utf8', function (err, data) {
151147
if (err) {
@@ -168,13 +164,9 @@ In this tutorial, you learn how to:
168164
- Update `index.cs` and replace `Run` function with following codes.
169165
```c#
170166
[FunctionName("index")]
171-
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous)] HttpRequest req, ILogger log)
167+
public static IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous)] HttpRequest req, ExecutionContext context, ILogger log)
172168
{
173-
string indexFile = "index.html";
174-
if (Environment.GetEnvironmentVariable("HOME") != null)
175-
{
176-
indexFile = Path.Join(Environment.GetEnvironmentVariable("HOME"), "site", "wwwroot", indexFile);
177-
}
169+
var indexFile = Path.Combine(context.FunctionAppDirectory, "index.html");
178170
log.LogInformation($"index.html path: {indexFile}.");
179171
return new ContentResult
180172
{

0 commit comments

Comments
 (0)