ProvisionSample/Program.cs
/// <summary>
/// Gets the workspace collection access keys for the specified collection
/// </summary>
/// <param name="subscriptionId">The azure subscription id</param>
/// <param name="resourceGroup">The azure resource group</param>
/// <param name="workspaceCollectionName">The Power BI workspace collection name</param>
/// <returns></returns>
Gets the workspace collection access keys for the specified collection
Gets the workspace collection access keys for the specified collection
static async Task<WorkspaceCollectionKeys> ListWorkspaceCollectionKeys(string subscriptionId, string resourceGroup, string workspaceCollectionName)
        {
            var url = string.Format("{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.PowerBI/workspaceCollections/{3}/listkeys{4}", azureEndpointUri, subscriptionId, resourceGroup, workspaceCollectionName, version);
            HttpClient client = new HttpClient();
            using (client)
            {
                var request = new HttpRequestMessage(HttpMethod.Post, url);
                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", GetAzureAccessToken());
                request.Content = new StringContent(string.Empty);
                var response = await client.SendAsync(request);
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    var responseText = await response.Content.ReadAsStringAsync();
                    var message = string.Format("Status: {0}, Reason: {1}, Message: {2}", response.StatusCode, response.ReasonPhrase, responseText);
                    throw new Exception(message);
                }
                var json = await response.Content.ReadAsStringAsync();
                return SafeJsonConvert.DeserializeObject<WorkspaceCollectionKeys>(json);
            }
        }
static async Task < WorkspaceCollectionKeys > ListWorkspaceCollectionKeys ( string subscriptionId , string resourceGroup , string workspaceCollectionName ) { var url = string . Format ( " " , azureEndpointUri , subscriptionId , resourceGroup , workspaceCollectionName , version ) ; HttpClient client = new HttpClient ( ) ; using ( client ) { var request = new HttpRequestMessage ( HttpMethod . Post , url ) ; request . Headers . Authorization = new AuthenticationHeaderValue ( " " , GetAzureAccessToken ( ) ) ; request . Content = new StringContent ( string . Empty ) ; var response = await client . SendAsync ( request ) ; if ( response . StatusCode != HttpStatusCode . OK ) { var responseText = await response . Content . ReadAsStringAsync ( ) ; var message = string . Format ( " " , response . StatusCode , response . ReasonPhrase , responseText ) ; throw new Exception ( message ) ; } var json = await response . Content . ReadAsStringAsync ( ) ; return SafeJsonConvert . DeserializeObject < WorkspaceCollectionKeys > ( json ) ; } }
Gets the workspace collection access keys for the specified collection
Gets the workspace collection access keys for the specified collection
// Set authorization header from you acquired Azure AD token
None
subscriptionId
string
The azure subscription id
The azure subscription id
resourceGroup
string
The azure resource group
The azure resource group
workspaceCollectionName
string
The Power BI workspace collection name
The Power BI workspace collection name