Example #1
0
        public static async Task LoginAndUpdateSKUAsync(string newSku)
        {
            string tenantId     = ConfigurationManager.AppSettings["AzureTenantId"];
            string clientId     = ConfigurationManager.AppSettings["AzureClientId"];
            string clientSecret = ConfigurationManager.AppSettings["AzureClientSecret"];

            string token = await AuthenticationHelpers.AcquireTokenBySPN(tenantId, clientId, clientSecret);

            using (var client = new HttpClient(new HttpClientHandler()))
            {
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
                client.BaseAddress = new Uri("https://management.azure.com/");
                var requestUri = $"/subscriptions/{Subscription}/resourceGroups/{ResourceGroup}/providers/Microsoft.AnalysisServices/servers/{AnalysisServicesResource}?api-version=2016-05-16";
                using (var response = await client.GetAsync(requestUri))
                {
                    response.EnsureSuccessStatusCode();
                    string responseBody = await response.Content.ReadAsStringAsync();

                    var json = IterateJsonAndReplaceSku(responseBody, newSku);
                    using (var newResponse = await client.PutAsJsonAsync(requestUri, json))
                    {
                        newResponse.EnsureSuccessStatusCode();
                    }
                }
            }
        }
Example #2
0
        public static async Task <string> LoginAndGetAnalysisServicesPropertyValue(string propertyName, string path)
        {
            string tenantId     = ConfigurationManager.AppSettings["AzureTenantId"];
            string clientId     = ConfigurationManager.AppSettings["AzureClientId"];
            string clientSecret = ConfigurationManager.AppSettings["AzureClientSecret"];

            string token = await AuthenticationHelpers.AcquireTokenBySPN(tenantId, clientId, clientSecret);

            using (var client = new HttpClient(new HttpClientHandler()))
            {
                client.DefaultRequestHeaders.Add("Authorization", "Bearer " + token);
                client.BaseAddress = new Uri("https://management.azure.com/");
                var requestUri = $"/subscriptions/{Subscription}/resourceGroups/{ResourceGroup}/providers/Microsoft.AnalysisServices/servers/{AnalysisServicesResource}?api-version=2016-05-16";
                using (var response = await client.GetAsync(requestUri)) // 2017-08-01-beta
                {
                    response.EnsureSuccessStatusCode();
                    string responseBody = await response.Content.ReadAsStringAsync();

                    return(GetAASProperty(responseBody, propertyName, path));
                }
            }
        }