The code snippet doesn't make any sense. Where does 'excluded' come from?
It seems like the author wanted to use the variable named 'collection' instead.
var collection = new DocumentCollection { Id = "excludedPathCollection" };
collection.IndexingPolicy.IncludedPaths.Add(new IncludedPath { Path = "/" });
collection.IndexingPolicy.ExcludedPaths.Add(new ExcludedPath { Path = "/nonIndexedContent/");
collection = await client.CreateDocumentCollectionAsync(UriFactory.CreateDatabaseUri("db"), excluded);
⚠Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
@DarinMacRae Thank you for inquiry. The indexing policy section of the Performance tips for Azure Cosmos DB and .NET SDK v2 document pertains to creating a client session based indexing policy for the purpose of increasing write performance. It does this by including an ExcludePath variable where nonindexed content for the document path could be detailed minimizing the total index operation needed to take place on a per document basis. Overall, this increases write operations. Please see: Include/Exclude Strategy for more precise detail. I hope this addresses your question.
Hey @Mike-Ubezzi-MSFT thanks for getting back to me.
I didn't have a question though, I was pointing out that the example provided in that documentation is broken.

@DarinMacRae Thank you for the additional detail. The sample is supposed to create a new collection with the detailed indexing policy and is not complete. I will have this reviewed and corrected as appropriate.
@DarinMacRae Looks that that statement should be fixed to. I can fix the doc:
collection = await client.CreateDocumentCollectionAsync(UriFactory.CreateDatabaseUri("db"), collection);
The above PR fixes the example, we will now close this issue.