Skip to content
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

Change Azd deployment scope from subscription to RG #281

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ You can deploy the application using one of the following options:
- [1. Azure Developer CLI](#azure-developer-cli)
- [2. Azure Portal Deployment](#azure-portal-deployment)

### 1. Azure Developer CLI
### 1. Azure Developer CLI (Resource group scoped deployment)

> **Important**
> This section will create Azure resources and deploy the solution from your local environment using the Azure Developer CLI. Note that you do not need to clone this repo to complete these steps.

1. Download the [Azure Developer CLI](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/overview)
1. If you have not cloned this repo, run `azd init -t microsoft/azurechat`. If you have cloned this repo, just run 'azd init' from the repo root directory.
1. Enable Resource Group scoping for `azd` based deployments to target the deployment scope to resource group from defalt subscription scope by executing `azd config set alpha.resourceGroupDeployments on`. Note that [this feature](https://learn.microsoft.com/azure/developer/azure-developer-cli/resource-group-scoped-deployments) is still in early stages of deveopment.
1. Set the environment variables for pointing the deployment to the resource group by running `azd env set AZURE_RESOURCE_GROUP <existing-rg-name>`. In case you don't have existing resource groups, you can create one using [Azure portal](https://learn.microsoft.com/azure/azure-resource-manager/management/manage-resource-groups-portal#create-resource-groups) or [CLI](https://learn.microsoft.com/azure/azure-resource-manager/management/manage-resource-groups-cli#create-resource-groups).
1. If you have not cloned this repo, run `azd init -t microsoft/azurechat`. If you have cloned this repo, just run `azd init` from the repo root directory.
1. Run `azd up` to provision and deploy the application

### 2. Azure Portal Deployment
Expand Down
10 changes: 1 addition & 9 deletions infra/main.bicep
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
targetScope = 'subscription'
targetScope = 'resourceGroup'

@minLength(1)
@maxLength(64)
Expand Down Expand Up @@ -40,16 +40,8 @@ param resourceGroupName string = ''
var resourceToken = toLower(uniqueString(subscription().id, name, location))
var tags = { 'azd-env-name': name }

// Organize resources in a resource group
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: !empty(resourceGroupName) ? resourceGroupName : 'rg-${name}'
location: location
tags: tags
}

module resources 'resources.bicep' = {
name: 'all-resources'
scope: rg
params: {
name: name
resourceToken: resourceToken
Expand Down