Forum Discussion
Cannot provision SP modern site with Group programmatically - "Alias is already in use"
Hi,
I'm building a solution that can provision O365 Groups with associated Modern Team Site and Teams.
While trying to create some new Sites with Groups, sometimes the creation fails with the error message "The alias for the group already exists".
Provisioning :
Tried both using New-PnPSite from PnP PowerShell v2.28.1807.0 , as calling directly the REST API /_api/GroupSiteManager/CreateGroupEx
with the same result (error)
Payload:
{"displayName":"TestPosh2",
"alias":"13015",
"isPublic":false,
"optionalParams":{"Description":"","CreationOptions":{"results":[],"Classification":""}}}
Response:
{"error":{"code":"-2147024713, Microsoft.SharePoint.SPException","message":{"lang":"nl-NL","value":"De alias voor de groep bestaat al."}}}
There isn't any visible existing Alias created in the tenant with that ID.
To verify this I did check
- Exchange Admin Center
- Get-UnifiedGroup (Exchange)
- Get-PnPUnifiedGroup
- /_api/GroupSiteManager/GetValidSiteUrlFromAlias?alias='13015'
They all return no matching data, the last one returns an OK status code with the available URL for site:
http://tenant.sharepoint.com/sites/13015
How can I further see whether this alias can be in use, or successfully use it for the new site?
4 Replies
- Ryan DennisCopper Contributor
I'm seeing the same issue in a customer tenant, no modern sites w/ groups are able to be created. In fact, we're not able to do so using any of the following approaches:
- Programmatically via Azure Function
- Using PNP PowerShell (New-PnPSite)
- Using the modern administration portal Create Site link
- Massimo ProtaCopper Contributor
We're now using this approach:
http://johnliu.net/blog/2017/1/create-many-o365-groups-with-powershell-resource-owner-granttype-and-microsoft-graph
so using an AAD app identity with delegated permissions, and calling into MS Graph.
It is in general more reliable than other approaches you mentioned, and we've tried as well. Especially in regards with the associated SP modern site, which gets provisioned in a timely fashion consistently with this approach
Hope it helps
- paulpaschaBronze Contributor
Hi Massimo,
Could it be a site with the same URL / alias still exists in the Site Collection recycle bin? Does this error occur randomly for you or are you frequently deleting / recreating your modern SP sites with the same name / alias?
- Massimo ProtaCopper Contributor
Hi Paul,
it could very well be the case, but I'm not 100% sure.
Being these site collections, I'm looking at the Recycle Bin from (old) Admin Center, the list of deleted sites from New Preview Admin Center, and Exchange Admin Center.
In the last one, in my experience, a full historical list of groups provisioned is maintained: I don't see any item with assigned alias '13015' there, and for other groups that have been deleted I can correctly re-assign that alias. So I'd say it happens randomly.
I don't think there're other places then to look and find for match.
Thanks for your answer, and thinking together.
Cheers
Massimo