Azure Rest API与SAS服务的使用

Azure Rest API与SAS服务的使用,azure,rest,Azure,Rest,我正在尝试使用Azure与。虽然我使用最基本的GET命令实现了这一点,但当我需要将变量添加到调用中时,设置就遇到了问题,因为变量与SAS令牌添加在同一位置。e、 g.对于“列表容器”,我应该使用URL“https://myaccount.blob.core.windows.net/?comp=list". 但是“?comp=list”部分与SAS令牌位于同一位置。如何将令牌和变量同时提供给请求?(我对RESTAPI没有太多经验,所以可能我误解了什么)。我也在下面发布了我的代码 using Sys

我正在尝试使用Azure与。虽然我使用最基本的GET命令实现了这一点,但当我需要将变量添加到调用中时,设置就遇到了问题,因为变量与SAS令牌添加在同一位置。e、 g.对于“列表容器”,我应该使用URL“https://myaccount.blob.core.windows.net/?comp=list". 但是“?comp=list”部分与SAS令牌位于同一位置。如何将令牌和变量同时提供给请求?(我对RESTAPI没有太多经验,所以可能我误解了什么)。我也在下面发布了我的代码

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;

namespace ConsoleProgram
{
    public class DataObject
    {
        public string Name { get; set; }
    }

    public class Class1
    {
        private const string URL = "url";
        private static string urlParameters = "?token";

        static void Main(string[] args)
        {
            HttpClient client = new HttpClient();
            client.BaseAddress = new Uri(URL);

            // Add an Accept header for JSON format.
            client.DefaultRequestHeaders.Accept.Add(
            new MediaTypeWithQualityHeaderValue("application/json"));

            // List data response.
            HttpResponseMessage response = client.GetAsync(urlParameters+ "&comp=list").Result;  // Blocking call! Program will wait here until a response is received or a timeout occurs.
            if (response.IsSuccessStatusCode)
            {
                Console.WriteLine(response.ToString());
                // Parse the response body.
                var dataObjects = response.Content.ReadAsStringAsync().Result;  //Make sure to add a reference to System.Net.Http.Formatting.dll
                Console.WriteLine("{0}", dataObjects);
            }
            else
            {
                Console.WriteLine("{0} ({1})", (int)response.StatusCode, response.ReasonPhrase);
            }

            // Make any other calls using HttpClient here.

            // Dispose once all HttpClient calls are complete. This is not necessary if the containing object will be disposed of; for example in this case the HttpClient instance will be disposed automatically when the application terminates so the following call is superfluous.
            client.Dispose();
        }
    }
}

当我们使用SAS令牌调用Azure blob rest API时,SAS令牌被用作查询字符串。因此,我们可以使用“&”来拼接SAS令牌和其他查询参数,例如
https://myaccount.blob.core.windows.net/?comp=list&{sasToken}

此外,请注意,如果要在一个存储帐户中列出容器,则需要创建帐户SAS令牌。服务SAS令牌无法实现它。关于如何创建帐户SAS令牌,请参阅