cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

Extend: `spo site add` command with Brand center option

Open mkm17 opened this issue 9 months ago • 21 comments

Usage

m365 spo site add [options]

Description

Creates a brand center site

Options

Option Description
--type [type] Type of sites to add. Allowed values TeamSite, CommunicationSite, ClassicSite, BrandCenter, default TeamSite

Examples

Create a brand center site.

m365 spo site add --type BrandCenter --url https://contoso.sharepoint.com/sites/brandcenter --title Branding

Default properties

No response

Additional Info

POST https://admin.microsoft.com/_api/SPSiteManager/Create

{"request":{"__metadata":{"type":"Microsoft.SharePoint.Portal.SPSiteCreationRequest"},"Title":"Brand Guide","Url":"https://contoso.sharepoint.com/sites/BrandGuide","WebTemplate":"SITEPAGEPUBLISHING#0","Classification":"","Description":"","SensitivityLabel":"00000000-0000-0000-0000-000000000000","Owner":"","SiteDesignId":"00000000-0000-0000-0000-000000000000","ShareByEmailEnabled":false,"Lcid":1033,"TimeZoneId":13,"AdditionalSiteFeatureIds":{"results":["99cd6e8b-189b-4611-ae89-f89105876e43"]}}}

Before executing this command, we need to check if the Brand Center already exists. (As only one brand center can exist).

As suggested by @milanholemans we should also prompt the user for confirmation and notify that the site cannot be deleted.

In the layout there was a checkbox that needed to be accepted (related to the public CDN) before creating the Brand Center, but I can no longer see it. However, it might be a good idea to ask the same question before executing the command.

Image

mkm17 avatar Apr 02 '25 20:04 mkm17

@milanholemans can you add it to the #6652 parent?

mkm17 avatar Apr 02 '25 20:04 mkm17

@mkm17 I suggest that we add a -f, --force flag like we do for removing commands. However this is not a destructive command, it is something that is irreversible. In this prompt we can warn the user that the site cannot be removed.

milanholemans avatar Apr 04 '25 22:04 milanholemans

@milanholemans ok, I have added the option

mkm17 avatar Apr 06 '25 10:04 mkm17

@mkm17 thinking about it some more, shouldn't we also have an option called url where the user can specify the URL of the site? Maybe also a title and an optional description?

milanholemans avatar Apr 09 '25 22:04 milanholemans

@milanholemans have added url, title and description, but maybe we can use more parameters used already in spo site add command. like --timeZone, --lcid --owners and --classification.

mkm17 avatar Apr 16 '25 16:04 mkm17

Maybe we should just enhance spo site add with the possibility of adding a brand center. When the type brandCenter is picked, we can still show a prompt. This means we won't have to duplicate almost an entire command. Any second opinion @pnp/cli-for-microsoft-365-maintainers?

milanholemans avatar Apr 16 '25 20:04 milanholemans

Maybe we should just enhance spo site add with the possibility of adding a brand center. When the type brandCenter is picked, we can still show a prompt. This means we won't have to duplicate almost an entire command. Any second opinion @pnp/cli-for-microsoft-365-maintainers?

Interesting suggestion. I don't have any strong opinion which approach is better as I think both have pros and cons. The only thing is that this command is kinda similar to tenant app catalog for which we also have separate command šŸ¤”. I think it is kind of a command that will not be used that frequent, most probably once per tenant šŸ˜‰. And if we have a separate command for it then it will increase viability of this. Most probable folks will notice a separate command rather then an additional example in the spo site add command. When it comes for duplicated logic I guess we should extract as much as possible to utils. We could check how the appcatalog add or site appcatalog add do it as I guess they also use same logic

Adam-it avatar Apr 17 '25 05:04 Adam-it

I'm not a huge fan of duplicating code either, but as @Adam-it mentioned, separating the command makes it easier to find. That being said, you could argue the same for many other options in commands, they could be more discoverable if separated. Since this won't be a frequently used command per tenant, I’d lean towards implementing it within spo site add. That way, we reduce the amount of code to manage šŸ˜„

Jwaegebaert avatar Apr 17 '25 14:04 Jwaegebaert

@Jwaegebaert @Adam-it @milanholemans, why can't we include both options? We can extract the site creation code and reuse it for different scenarios: a regular site, a Brand Center site (which appears to be a Community site with an additional site feature), and potentially even a SharePoint Premium Content Center site.

I need to explore this further, but there might be a way to simply set a site as a Brand Center by enabling a site feature, and 'remove' the Brand Center by disabling that same feature. However, I need to check if there are any consequences, as this option doesn't seem to be available in the admin center.

mkm17 avatar Apr 18 '25 20:04 mkm17

@Jwaegebaert @Adam-it @milanholemans, why can't we include both options? We can extract the site creation code and reuse it for different scenarios: a regular site, a Brand Center site (which appears to be a Community site with an additional site feature), and potentially even a SharePoint Premium Content Center site.

@mkm17 exactly šŸ‘ This is what I had in mind when I wrote

When it comes for duplicated logic I guess we should extract as much as possible to utils. We could check how the appcatalog add or site appcatalog add do it as I guess they also use same logic

We already do this in several places were common logic is extracted and reshared between multiple commands. I think this approach makes most sense IMO šŸ‘

I need to explore this further, but there might be a way to simply set a site as a Brand Center by enabling a site feature, and 'remove' the Brand Center by disabling that same feature. However, I need to check if there are any consequences, as this option doesn't seem to be available in the admin center.

good find. It would be interested if it would work this way as in this case it would be quite flexible and we could have commands allowing it to activate and deactivate

Adam-it avatar Jun 09 '25 10:06 Adam-it

I need to explore this further, but there might be a way to simply set a site as a Brand Center by enabling a site feature, and 'remove' the Brand Center by disabling that same feature. However, I need to check if there are any consequences, as this option doesn't seem to be available in the admin center.

good find. It would be interested if it would work this way as in this case it would be quite flexible and we could have commands allowing it to activate and deactivate

In this case, we'll have to check if it's actually supported to do so.

milanholemans avatar Jun 10 '25 19:06 milanholemans

How different is the code for adding a brandcenter site vs a regular site? If it's just a matter of specifying the site template, then I suggest we merge it with spo site add. If it's using a different API, then I suggest that we build a separate command to avoid the code getting too complex.

waldekmastykarz avatar Jun 16 '25 09:06 waldekmastykarz

@waldekmastykarz the only difference I can see is the additional feature that needs to be enabled on the site. If that's the case, and we decide not to create a separate command, then maybe we can follow the same approach as with the removal of the SharePoint page header. Instead of creating a new command, we could just provide an example script to create/configure the Brand Center. This would be a very simple solution, just using the existing spo site add and spo feature enable commands.

mkm17 avatar Jun 26 '25 20:06 mkm17

That sounds like a fair approach. Providing an example script using spo site add and spo feature enable makes sense if the only difference is toggling that feature flag.

Jwaegebaert avatar Jun 27 '25 12:06 Jwaegebaert

@pnp/cli-for-microsoft-365-maintainers I think this issue has become a bit stale and we only need to decide for the approach. I think we all agreed that we rather not add a separate command for it as most probably it would not be used that often, although its worth pointing out that for tenant app catalog we have a separate command so I am only afraid it may seem inconsistent.

Now we should rather decide if:

  1. we want to add a separate script sample for it which would be a combination of site add and feature enable.
  2. or we want to expose this as an additional option in the site add command.

I vote for 2nd option

Adam-it avatar Aug 26 '25 14:08 Adam-it

Thanks for reviving this issue @Adam-it. My vote would go to option 2 as well.

milanholemans avatar Aug 26 '25 18:08 milanholemans

+1 on option 2

Jwaegebaert avatar Aug 29 '25 06:08 Jwaegebaert

Ok, so I think I can change the description of the command to an update of site add :)

mkm17 avatar Sep 02 '25 19:09 mkm17

Ok, so I think I can change the description of the command to an update of site add :)

Perfect. Let's open it up @mkm17 did you maybe want to take action on that and implement it?

It's gonna be hard to review it in my case as I already have brand center on my dev tenant 😁

Adam-it avatar Oct 19 '25 18:10 Adam-it

@Adam-it I can take it :) Some time ago, it was possible to remove the Brand Center by disabling the feature mentioned in the task.

mkm17 avatar Oct 19 '25 20:10 mkm17

@mkm17 all yours šŸ‘šŸ‘šŸ‘šŸ‘šŸ‘

Adam-it avatar Oct 19 '25 21:10 Adam-it