简体   繁体   English

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

[英]C# to pause, turn on ssas server, backup cube… how to?

I'm building some function apps in C# (via REST API) to make refreshes of tabular cube located on an azure ssas server. 我正在C#中构建一些功能应用程序(通过REST API)以刷新位于天蓝色的ssas服务器上的表格多维数据集。 So far, no problem. 到目前为止,没有问题。 However, I can't find a way to pause/start the ssas server (I saw some doc in powershell but I'd like to stay in C# so as not to mix languages) 但是,我找不到暂停/启动ssas服务器的方法(我在powershell中看到了一些文档,但我希望保留在C#中,以便不混合语言)

Has anyone ever created anything like this? 有没有人创造过这样的东西?

I tried to make a POST suspend but no solution for now. 我试图使POST挂起,但暂时没有解决方案。

See the ResumeAzureAS() method here : 这里查看ResumeAzureAS()方法:

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;

        }

The rest of the API calls (such as suspend) are documented here . 其余API调用(例如suspend)在此处记录

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;

    } 

With audience set as " https://management.azure.com " 将受众设置为“ https://management.azure.com

and for the "pause" itself : I use as servername the complete name mention in the portal azure as "asazure://northeurope.asazure.windows...." For the version of the api , well I don't know where to find it so I use one I found on the net. 对于“ 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/";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM