几次部署后,Azure函数中的查询会停止工作吗?

时间:2019-04-21 15:09:52

标签: azure azure-functions

我刚刚开始使用天蓝色函数。按照说明here,我修改了代码,并deploy将其修改为我的函数

RewriteEngine on

RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{SCRIPT_FILENAME} !-f
RewriteRule ^/(.*)$ /index.php/$1 [L]

结合我的代码

    [FunctionName("Function1")]
    public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
    {
        log.Info("C# HTTP trigger function processed a request.");

        // parse query parameter
        string name = req.GetQueryNameValuePairs()
            .FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0)
            .Value;

        if (name == null)
        {
            // Get request body
            dynamic data = await req.Content.ReadAsAsync<object>();
            name = data?.name;
        }

        return name == null
            ? req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a name on the query string or in the request body")
            : req.CreateResponse(HttpStatusCode.OK, "Hello " + Multiply().ToString());
    }

该功能在部署时成功运行,但经过几次重新构建和部署后,该信息仍然显示

enter image description here

删除public static int Multipy() { Random rnd = new Random(); return rnd.Next(1, 10)*rnd.Next(1, 10); } 查询并照常工作

enter image description here

我的代码是否存在问题,或者Azure的部署功能受到限制?我该如何解决?

1 个答案:

答案 0 :(得分:2)

查询符号不是问题吗?它已经被?使用过,因此另一个参数应加上&符号

{url}?code={someCode}&name={name}