英文:
GitHub Action command to create an Azure Resource Group from JSON ARM Template
问题
我正在尝试从ARM JSON模板中创建和删除Azure资源组。我手动尝试创建了一个资源组,并从Azure门户保存了模板。
以下是资源组的ARM模板的Json版本:
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.1",
"parameters": {
"rgName": {
"type": "string"
},
"rgLocation": {
"type": "string"
},
"tags": {
"type": "object",
"defaultValue": {}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2018-05-01",
"location": "[parameters('rgLocation')]",
"name": "[parameters('rgName')]",
"properties": {},
"tags": "[parameters('tags')]"
}
],
"outputs": {}
}
我想要的是在部署资源之前创建一个资源组。之后我想销毁整个资源组以及其下的资源。
以下是部署资源到资源组的Workflow示例:
- name: 部署函数应用程序资源
uses: azure/arm-deploy@v1
with:
scope: resourcegroup
subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }}
resourceGroupName: ${{ env.AZURE_RESOURCE_GROUP }}
parameters: ./parameters.json
template: ./azure-deploy-function-api.json
英文:
I'm trying to create and delete an Azure Resource Group from the ARM JSON Template. I manually tried to create a Resource Group and saved the Template from the Azure Portal.
Here is the Json version of the ARM template for the Resource Group:
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.1",
"parameters": {
"rgName": {
"type": "string"
},
"rgLocation": {
"type": "string"
},
"tags": {
"type": "object",
"defaultValue": {}
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2018-05-01",
"location": "[parameters('rgLocation')]",
"name": "[parameters('rgName')]",
"properties": {},
"tags": "[parameters('tags')]"
}
],
"outputs": {}
}
I want is to create a Resource Group and later destroy the Resource Group from a GitHub Workflow. I have already some Workflow script to deploy resources in a Resource Group. An example is below:
- name: Deploy Function App Resources
uses: azure/arm-deploy@v1
with:
scope: resourcegroup
subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }}
resourceGroupName: ${{ env.AZURE_RESOURCE_GROUP }}
parameters: ./parameters.json
template: ./azure-deploy-function-api.json
What I want is to create the Resource Group before deploying the resources to it. Later I want destroy the whole Resource Group and the resources underneath it.
答案1
得分: 1
如果要部署资源组,您需要在此更改范围,然后您也不需要 resourceGroupName
参数(您不能在资源组范围内部署资源组)。
- name: 部署函数应用资源
uses: azure/arm-deploy@v1
with:
scope: 订阅
subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }}
parameters: ./parameters.json
template: ./azure-deploy-function-api.json
region: 东部美国
在此处查看有关此 操作 的更多详细信息。
英文:
If you want to deploy resource group you need to change here the scope and then you also don't need resourceGroupName
parameter. (You simply cannot deploy resource group in resource group scope).
- name: Deploy Function App Resources
uses: azure/arm-deploy@v1
with:
scope: subscription
subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }}
parameters: ./parameters.json
template: ./azure-deploy-function-api.json
region: eastus
Here you find more details for this action.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论