Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#要暂停,请打开ssas服务器、备份多维数据集。。。。如何?_C#_Azure Functions_Ssas Tabular_Azure Analysis Services_Azure Function App - Fatal编程技术网

C#要暂停,请打开ssas服务器、备份多维数据集。。。。如何?

C#要暂停,请打开ssas服务器、备份多维数据集。。。。如何?,c#,azure-functions,ssas-tabular,azure-analysis-services,azure-function-app,C#,Azure Functions,Ssas Tabular,Azure Analysis Services,Azure Function App,我正在用C#(通过RESTAPI)构建一些函数应用程序,以刷新azure ssas服务器上的表格多维数据集。到目前为止,没有问题。但是,我找不到暂停/启动ssas服务器的方法(我在powershell中看到一些文档,但我想留在C中,以免混合语言) 有人创造过这样的东西吗 我试图进行POST挂起,但目前没有解决方案。请参阅ResumeAzureAS()方法: 受保护的异步任务ResumeAzureAS() { HttpClient=新的HttpClient(); var apiURI=新Uri(s

我正在用C#(通过RESTAPI)构建一些函数应用程序,以刷新azure ssas服务器上的表格多维数据集。到目前为止,没有问题。但是,我找不到暂停/启动ssas服务器的方法(我在powershell中看到一些文档,但我想留在C中,以免混合语言)

有人创造过这样的东西吗


我试图进行POST挂起,但目前没有解决方案。

请参阅
ResumeAzureAS()
方法:

受保护的异步任务ResumeAzureAS()
{
HttpClient=新的HttpClient();
var apiURI=新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(新的MediaTypeWithQualityHeaderValue(“应用程序/json”);
client.DefaultRequestHeaders.Authorization=新的AuthenticationHeaderValue(“承载者”,accessToken);
HttpResponseMessage response=wait client.PostAsync(apiURI.ToString(),null);
response.EnsureSuccessStatusCode();
返回true;
}

其余的API调用(如suspend)都有文档记录

合适的观众是:

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

你好,谢谢你的回答。我采用了与您描述的相同的方法,但收到了一个“禁止”错误。我怀疑问题来自代币的生成。我会检查问题的来源。谢谢你的提示。我会帮你保管这封信的progress@MiguelMartinPerez您使用的任何身份都需要在Azure门户中Azure AS服务器的访问控制(IAM)选项卡中提供权限。欢迎分享您的代币生成代码。首先,感谢您的帮助和快速回答。我做了一些测试,没有办法做暂停或恢复;我有一个403错误。暂停消费与刷新的令牌生成是否需要不同?@MiguelMartinPerez是的。它与刷新不同。当你发布你的代币生成代码时,我们可以看看它。你好,在经历了几次挫折之后,因为我非常确信我的代码是正确的。。。我找到了根本原因;观众完全错了。正确的受众是受众=”;
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;

    } 
        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/";