C# 暂停,打开 ssas 服务器,备份多维数据集....怎么办?

C# to pause, turn on ssas server, backup cube.... how to?

我正在用 C# 构建一些函数应用程序(通过 REST API)来刷新位于 azure ssas 服务器上的表格立方体。到目前为止,没问题。但是,我找不到 pause/start ssas 服务器的方法(我在 powershell 中看到了一些文档,但我想留在 C# 中以免混合语言)

有没有人创造过这样的东西?

我试过 POST 暂停,但暂时没有解决方案。

参见ResumeAzureAS()方法here:

protected async Task<bool> ResumeAzureAS()
        {
            HttpClient client = new HttpClient();
            var apiURI = new Uri(string.Format("https://management.azure.com/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.AnalysisServices/servers/{2}/resume?api-version=2016-05-16", subscriptionID, resourcegroup, server));

            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);

            HttpResponseMessage response = await client.PostAsync(apiURI.ToString(), null);
            response.EnsureSuccessStatusCode();
            return true;
        }

其余 API 调用(例如挂起)已记录在案 here

private async Task<string> AASAcquireToken()
    {
        // Get auth token and add the access token to the authorization header of the request.
        string authority = "https://login.windows.net/" + tenant + "/oauth/authorize";
        AuthenticationContext ac = new AuthenticationContext(authority);
        ClientCredential cred = new ClientCredential(clientID, keyID);
        AuthenticationResult ar = await ac.AcquireTokenAsync(audience, cred);
        return ar.AccessToken;

    } 

观众设置为“https://management.azure.com

以及 "pause" 本身: 我将门户网站 azure 中提及的完整名称用作服务器名 "asazure://northeurope.asazure.windows...." 对于 api 的版本,我不知道在哪里可以找到它,所以我使用了我在网上找到的一个。

        var apiURI = new Uri(string.Format("https://management.azure.com/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.AnalysisServices/servers/{2}/suspend?api-version=2016-05-16", subscription, ressourceID, servername));

        audience = "https://management.azure.com";

        myClient.BaseAddress = new Uri(location);
        myClient.DefaultRequestHeaders.Accept.Clear();
        myClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        myClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", await AASAcquireToken());

        HttpResponseMessage response = await myClient.PostAsync(apiURI.ToString(), null);
        var output = await response.Content.ReadAsStringAsync();

        response.EnsureSuccessStatusCode();

正确的观众是:

audience = "https://management.core.windows.net/";