-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Add search resource #42610
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add search resource #42610
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
26a15f5
Add search resource
JoshLove-msft e21c3e5
update test
JoshLove-msft 5d049a0
update test case
JoshLove-msft 30155a0
Merge branch 'feature/cdk' of https://github.com/Azure/azure-sdk-for-…
JoshLove-msft be3f998
assets
JoshLove-msft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
sdk/provisioning/Azure.Provisioning/src/search/SearchService.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System; | ||
| using Azure.Core; | ||
| using Azure.Provisioning.Redis; | ||
| using Azure.Provisioning.ResourceManager; | ||
| using Azure.ResourceManager.Search; | ||
| using Azure.ResourceManager.Search.Models; | ||
|
|
||
| namespace Azure.Provisioning.Search | ||
| { | ||
| /// <summary> | ||
| /// Represents a search service resource. | ||
| /// </summary> | ||
| public class SearchService : Resource<SearchServiceData> | ||
| { | ||
| private const string ResourceTypeName = "Microsoft.Search/searchServices"; | ||
| private static readonly Func<string, SearchServiceData> Empty = (name) => ArmSearchModelFactory.SearchServiceData(); | ||
| internal const string DefaultVersion = "2023-11-01"; | ||
|
|
||
| /// <summary> | ||
| /// Creates a new instance of the <see cref="SearchService"/> class. | ||
| /// </summary> | ||
| /// <param name="scope"></param> | ||
| /// <param name="sku"></param> | ||
| /// <param name="parent"></param> | ||
| /// <param name="name"></param> | ||
| /// <param name="version"></param> | ||
| /// <param name="location"></param> | ||
| public SearchService(IConstruct scope, SearchSkuName? sku = default, ResourceGroup? parent = default, string name = "search", string version = DefaultVersion, AzureLocation? location = default) | ||
| : this(scope, sku, parent, name, version, false, (name) => ArmSearchModelFactory.SearchServiceData( | ||
| name: name, | ||
| location: location ?? Environment.GetEnvironmentVariable("AZURE_LOCATION") ?? AzureLocation.WestUS, | ||
| skuName: sku ?? SearchSkuName.Basic)) | ||
| { | ||
| AssignProperty(data => data.Name, GetAzureName(scope, name)); | ||
| } | ||
|
|
||
| private SearchService(IConstruct scope, SearchSkuName? sku = default, ResourceGroup? parent = default, string name = "search", string version = DefaultVersion, bool isExisting = false, Func<string, SearchServiceData>? creator = null) | ||
| : base(scope, parent, name, ResourceTypeName, version, creator ?? Empty, isExisting) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates a new instance of the <see cref="RedisCache"/> class referencing an existing instance. | ||
| /// </summary> | ||
| /// <param name="scope">The scope.</param> | ||
| /// <param name="name">The resource name.</param> | ||
| /// <param name="parent">The resource group.</param> | ||
| /// <returns>The KeyVault instance.</returns> | ||
| public static SearchService FromExisting(IConstruct scope, string name, ResourceGroup? parent = null) | ||
| => new SearchService(scope, parent: parent, name: name, isExisting: true); | ||
|
|
||
| /// <inheritdoc/> | ||
| protected override string GetAzureName(IConstruct scope, string resourceName) => GetGloballyUniqueName(resourceName); | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
sdk/provisioning/Azure.Provisioning/tests/Infrastructure/Search/main.bicep
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| targetScope = 'resourceGroup' | ||
|
|
||
| @description('') | ||
| param location string = resourceGroup().location | ||
|
|
||
|
|
||
| resource searchService_cwdgn2HGu 'Microsoft.Search/searchServices@2023-11-01' = { | ||
| name: toLower(take(concat('search', uniqueString(resourceGroup().id)), 24)) | ||
| location: location | ||
| sku: { | ||
| name: 'standard' | ||
| } | ||
| properties: { | ||
| replicaCount: 1 | ||
| partitionCount: 1 | ||
| hostingMode: 'default' | ||
| disableLocalAuth: true | ||
| } | ||
| } | ||
|
|
||
| resource roleAssignment_dcgUqp8kp 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
| scope: searchService_cwdgn2HGu | ||
| name: guid(searchService_cwdgn2HGu.id, '00000000-0000-0000-0000-000000000000', subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7ca78c08-252a-4471-8644-bb5ff32d4ba0')) | ||
| properties: { | ||
| roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7ca78c08-252a-4471-8644-bb5ff32d4ba0') | ||
| principalId: '00000000-0000-0000-0000-000000000000' | ||
| principalType: 'ServicePrincipal' | ||
| } | ||
| } | ||
|
|
||
| resource roleAssignment_1CP5SnX3w 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
| scope: searchService_cwdgn2HGu | ||
| name: guid(searchService_cwdgn2HGu.id, '00000000-0000-0000-0000-000000000000', subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8ebe5a00-799e-43f5-93ac-243d3dce84a7')) | ||
| properties: { | ||
| roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '8ebe5a00-799e-43f5-93ac-243d3dce84a7') | ||
| principalId: '00000000-0000-0000-0000-000000000000' | ||
| principalType: 'ServicePrincipal' | ||
| } | ||
| } | ||
|
|
||
| output connectionString string = 'Endpoint=https://${searchService_cwdgn2HGu.name}.search.windows.net' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.