ProvisionSample/Program.cs
/// <summary>
/// Creates a new Power BI Embedded workspace 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 to create</param>
/// <returns></returns>
Creates a new Power BI Embedded workspace collection
Creates a new Power BI Embedded workspace collection
static async Task CreateWorkspaceCollection(string subscriptionId, string resourceGroup, string workspaceCollectionName)
        {
            var url = string.Format("{0}/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.PowerBI/workspaceCollections/{3}{4}", azureEndpointUri, subscriptionId, resourceGroup, workspaceCollectionName, version);
            HttpClient client = new HttpClient();
            using (client)
            {
                var content = new StringContent(@"{
                                                ""location"": ""southcentralus"",
                                                ""tags"": {},
                                                ""sku"": {
                                                    ""name"": ""S1"",
                                                    ""tier"": ""Standard""
                                                }
                                            }", Encoding.UTF8);
                content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8");
                var request = new HttpRequestMessage(HttpMethod.Put, url);
                request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", GetAzureAccessToken());
                request.Content = content;
                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;
            }
        }
static async Task CreateWorkspaceCollection ( string subscriptionId , string resourceGroup , string workspaceCollectionName ) { var url = string . Format ( " " , azureEndpointUri , subscriptionId , resourceGroup , workspaceCollectionName , version ) ; HttpClient client = new HttpClient ( ) ; using ( client ) { var content = new StringContent ( @"{
                                                ""location"": ""southcentralus"",
                                                ""tags"": {},
                                                ""sku"": {
                                                    ""name"": ""S1"",
                                                    ""tier"": ""Standard""
                                                }
                                            }" , Encoding . UTF8 ) ; content . Headers . ContentType = MediaTypeHeaderValue . Parse ( " " ) ; var request = new HttpRequestMessage ( HttpMethod . Put , url ) ; request . Headers . Authorization = new AuthenticationHeaderValue ( " " , GetAzureAccessToken ( ) ) ; request . Content = content ; 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 ; } }
Creates a new Power BI Embedded workspace collection
Creates a new Power BI Embedded workspace 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 to create
The Power BI workspace collection name to create