I have a simple ARM deployment script
az deployment group create \
--name <NAME> \
--resource-group <ResourceGroup> \
--template-file template.json \
--parameters #parameters.json
This has a template file
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"connections_ftp_name": {
"defaultValue": "ftp",
"type": "String"
}
},
"variables": {},
"resources": [
{
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"name": "[parameters('connections_ftp_name')]",
"location": "ukwest",
"kind": "V1",
"properties": {
"displayName": "[parameters('connections_ftp_name')]",
"customParameterValues": {},
"api": {
"id": "[concat('/subscriptions/SUBSCRIPTION/providers/Microsoft.Web/locations/ukwest/managedApis/', parameters('connections_ftp_name'))]"
}
}
}
]
}
And a parameter file
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"connections_ftp_name": {
"value": "my-name"
}
}
}
When I run this via Azure CLI I get the error
az deployment group create \
> --name DeployMonitorFtp5 \
> --resource-group middleware.prod.rg \
> --template-file template.json \
> --parameters #parameters.json
←[K←[K←[91mDeployment failed. Correlation ID: 1f5b34ad-3105-4dfd-b4ca-d38a98fb800a. {
"error": {
"code": "ApiNotFound",
"message": "The API 'my-name' could not be found."
}
}←[0m
This makes no sense at all given I want to create the resource!
Can someone help please?
Paul
IT is not related to Az Cli.
The api element should not referenced the parameter connections_ftp_name. it should be :
"api": {
"id": "[concat('/subscriptions/SUBSCRIPTION/providers/Microsoft.Web/locations/ukwest/managedApis/ftp')]"
}
When creating a logic app connector, you should also specify the connector, here is a complete sample to create a ftp connector:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"ftpConnectionAPIName": {
"type": "string",
"metadata": {
"description": "The name of the connection api to access the ftp."
}
},
"ftpServerAddress": {
"type": "string",
"metadata": {
"description": "The name of the ftp server address."
}
},
"ftpUsername": {
"type": "string",
"metadata": {
"description": "The name of the ftp user name."
}
},
"ftpPassword": {
"type": "securestring",
"metadata": {
"description": "The name of the ftp password."
}
}
},
"resources": [
{
"type": "Microsoft.Web/connections",
"name": "[parameters('ftpConnectionAPIName')]",
"apiVersion": "2016-06-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"displayName": "[parameters('ftpConnectionAPIName')]",
"parameterValues": {
"serverAddress": "[parameters('ftpServerAddress')]",
"userName": "[parameters('ftpUsername')]",
"password": "[parameters('ftpPassword')]"
},
"api": {
"id": "[concat('subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/ftp')]"
}
}
}
]
}
Related
I developing a method that accepts various messages and returns the some result. The main goal is that message formats can be added without rebuilding the project. Two types of the messages is below:
{
"PushToken": "ksjdfhskfhskdjfhskjdfhk",
"Alertе": "ssffsdfsdfsdfsdfsdfsfs sfsdfsdf sfsdfsdfs",
"Priority": 5,
"IsBackground": false
}
and
{
"DeviceToken": "ksjdfhskfhskdjfhskjdfhkkh7khsdfjk8sdfsdfsddddddddddddddd",
"Message": "ssffsdfsdfsdfsdfsdfsfs sfsdfsdf sfsdfsdfs",
"Title": "asdasdas",
"Condition": "asfdasf"
}
I thinked how to validate messages and decided using json schema's. They are below:
{
"title":"IOS",
"description": "IOS Message",
"type": "object",
"properties": {
"PushToken": { "type": "string", "maxLength": 50 },
"Alert": { "type": "string", "maxLength": 2000 },
"Priority": { "type": "number", "default": 10 },
"IsBackground": { "type": "boolean", "default": true }
},
"required":[
"PushToken",
"Alert"
],
"additionalProperties": false
}
and
{
"title":"Android",
"description": "Android message",
"type": "object",
"properties": {
"DeviceToken": { "type": "string", "maxLength": 50 },
"Message": { "type": "string", "maxLength": 2000 },
"Title": { "type": "string", "maxLength": 255 },
"Condition": { "type": "string", "maxLength": 2000 }
},
"required":[
"DeviceToken",
"Message",
"Title"
],
"additionalProperties": false
}
For validating I using thomething like that:
JSchema schema = JSchema.Parse(iosJsonSchema);
IList<string> errorMessages;
bool valid = iosJsonMessage.IsValid(schema, out errorMessages); //iosJsonMessage - JObject type
In IList<string> messages I receive all errors. In bool valid variable I receive validation result.
Is there a way to check only properties names of the json request? And only those names that are declare in required section of the json schema. I want to do this for understanding the type of the message.
And a more general question. Is this an acceptable solution for task that I described above?
Thanks.
I'm running out of time to get this done, but I just can't seem to find my issue.
I'm trying to deploy an ARM template that creates a new MCA subscription. The template works when deployed via Azure PowerShell, but when using the Azure SDK it gives the following error:
Microsoft.Rest.Azure.CloudException: 'Deployment template validation failed: 'The resource 'Microsoft.Subscription/aliases/devtestdeployasp22' referenced in output is not defined in the template. Please specify resource identifier and api version if the resource is outside of the template. Please see https://aka.ms/arm-template-expressions/#reference for usage details.'.'
var subscription = azure.Deployments
.Define("deployment_temp")
.WithNewResourceGroup("temprg", Region.USEast)
.WithTemplate(Utils.GetArmTemplate("<path_to_file_removed_for_privacy>"))
.WithParameters("{}")
.WithMode(Microsoft.Azure.Management.ResourceManager.Fluent.Models.DeploymentMode.Incremental)
.Create();
The template used with this contains:
{
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/managementGroupDeploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"subscriptionAliasName": {
"type": "string",
"metadata": {
"description": "Provide a name for the alias. This name will also be the display name of the subscription."
}
},
"billingScope": {
"type": "string",
"defaultValue": "<Removed>",
"metadata": {
"description": "Provide the full resource ID of billing scope to use for subscription creation."
}
},
"mgName": {
"type": "string",
"defaultValue": "mg-mission-default-dev",
"metadata": {
"description": "management group name"
}
}
},
"variables": {
"mgId": "[concat('Microsoft.Management/managementGroups/',parameters('mgName'))]"
},
"resources": [
{
"scope": "[variables('mgId')]",
"name": "[parameters('subscriptionAliasName')]",
"type": "Microsoft.Subscription/aliases",
"apiVersion": "2021-04-01",
"properties": {
"workLoad": "Production",
"displayName": "[parameters('subscriptionAliasName')]",
"billingScope": "[parameters('billingScope')]"
}
}
],
"outputs": {
"subscriptionID": {
"type": "string",
"value": "[reference(resourceId('Microsoft.Subscription/aliases', parameters('subscriptionAliasName'))).subscriptionId]"
}
}
}
Any help would be appreciated, or even an alternate path I could take but the goal is to create a new MCA subscription (with some resources) using C#.
You need to fetch the Subscription ID by using tenantResourceId -
tenantResourceId - Returns the unique identifier for a resource deployed at the tenant level.
"outputs": {
"subscriptionId": {
"type": "string",
"value": "[reference(tenantResourceId('Microsoft.Subscription/aliases', parameters('subscriptionAliasName'))).subscriptionId]"
}
}
Please refer this documentation.
I am wrting a Function ARM template for CI/CD the function is already hosted on the Azure portal Now I decided to create an ARM function template and am getting the below error. It saying I cannot create a resource which already exists. I know the resource already exists but I want to create a CI/CD pipline based on the template. I have tried the incremental mode but it seems I am missing something. Is there any guidance online? I have taken the Azure Function Template from the AZURE Git.
C:\Program Files\Microsoft SDKs\Azure.NET SDK\v2.9> az group deployment validate --mode Incremental --resource-group cloud-shell-storage-southeastasia --template-file azuredeploy.json
Please provide string value for 'appName' (? for help): SchedulerHttpFunctionSample
azuredeploy.json
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"type": "string",
"metadata": {
"description": "The name of the function app that you wish to create."
}
},
"storageAccountType": {
"type": "string",
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_RAGRS"
],
"metadata": {
"description": "Storage Account type"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
},
"runtime": {
"type": "string",
"defaultValue": "node",
"allowedValues": [
"node",
"dotnet",
"java"
],
"metadata": {
"description": "The language worker runtime to load in the function app."
}
}
},
"variables": {
"functionAppName": "[parameters('appName')]",
"hostingPlanName": "[parameters('appName')]",
"applicationInsightsName": "[parameters('appName')]",
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'azfunctions')]",
"storageAccountid": "[concat(resourceGroup().id,'/providers/','Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"functionWorkerRuntime": "[parameters('runtime')]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageAccountName')]",
"apiVersion": "2018-12-01",
"location": "[parameters('location')]",
"kind": "Storage",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"properties":{
"mode":"Incremental"
}
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[variables('hostingPlanName')]",
"location": "[parameters('location')]",
"sku": {
"name": "Y1",
"tier": "Dynamic"
},
"properties": {
"mode":"Incremental",
"name": "[variables('hostingPlanName')]",
"computeMode": "Dynamic"
}
},
{
"apiVersion": "2018-02-01",
"type": "Microsoft.Web/sites",
"name": "[variables('functionAppName')]",
"location": "[parameters('location')]",
"kind": "functionapp",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
],
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"mode":"Incremental",
"siteConfig": {
"appSettings": [
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[toLower(variables('functionAppName'))]"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~2"
},
{
"name": "WEBSITE_NODE_DEFAULT_VERSION",
"value": "~10"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId('microsoft.insights/components/', variables('applicationInsightsName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "[variables('functionWorkerRuntime')]"
}
]
}
}
},
{
"apiVersion": "2018-02-01",
"name": "[variables('applicationInsightsName')]",
"type": "microsoft.insights/components",
"location": "East US",
"tags": {
"[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('applicationInsightsName'))]": "Resource"
},
"properties": {
"ApplicationId": "[variables('applicationInsightsName')]",
"Request_Source": "IbizaWebAppExtensionCreate",
"mode":"Incremental"
}
}
]
}
Azure Error: InvalidResourceLocation
Message: The resource 'SchedulerHttpFunctionSample' already exists in location 'southcentralus' in resource group 'cloud-shell-storage-southeastasia'. A resource with the same name cannot be created in location 'southeastasia'. Please select a new resource name.
It's because that name is already taken. Function App name need to be globally unique.
I would suggest using a suffix. In the variables section create some variables:
"variables": {
"suffix": "[uniqueString(resourceGroup().id, resourceGroup().location)]",
"functionAppName": "[concat(parameters('appName'), variables('suffix'))]"
}
The function uniqueString will generate a unique string base on the information received. So if you redeploy in the same resource group and region the suffix will be the same.
Have a look to this post: http://www.frankysnotes.com/2019/05/how-to-make-your-deployment-successful.html or this video https://www.youtube.com/watch?v=dnb-f4C052w
when i am trying to configure tab in teams channel,i followed the steps from article https://learn.microsoft.com/en-in/microsoftteams/platform/tutorials/get-started-dotnet-app-studio i could not find selection of tab and save button enabled , why this happned? how to solve it?, I am using echo bot template which is running on bot emulator properly.
Following is the json
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.5/MicrosoftTeams.schema.json",
"manifestVersion": "1.5",
"version": "1.0.0",
"id": "2fac8fdd-7fa3-451f-8562-adba3ab84c8d",
"packageName": "com.contoso.helloworld",
"developer": {
"name": "Hello World App ",
"websiteUrl": "https://www.microsoft.com",
"privacyUrl": "https://www.microsoft.com/privacy",
"termsOfUseUrl": "https://www.microsoft.com/termsofuse"
},
"icons": {
"color": "color.png",
"outline": "outline.png"
},
"name": {
"short": "janApp",
"full": "janApp"
},
"description": {
"short": "SWAN Bot App for Microsoft Teams",
"full": "This sample app provides a very simple app for Microsoft Teams. You can extend this to add more content and capabilities."
},
"accentColor": "#A4D344",
"configurableTabs": [
{
"configurationUrl": "https://echobot57.azurewebsites.net/configure",
"canUpdateConfiguration": true,
"scopes": [
"team",
"groupchat"
]
}
],
"staticTabs": [
{
"entityId": "com.contoso.helloworld.hellotab",
"name": "Botdemo",
"contentUrl": "https://echobot57.azurewebsites.net/hello",
"websiteUrl": "https://echobot57.azurewebsites.net/hello",
"scopes": [
"personal"
]
}
],
"bots": [
{
"botId": "330b4c4d-5f92-4053-a38f-7d4593cfd18a",
"scopes": [
"personal",
"team",
"groupchat"
],
"supportsFiles": true,
"isNotificationOnly": true
}
],
"composeExtensions": [
{
"botId": "330b4c4d-5f92-4053-a38f-7d4593cfd18a",
"canUpdateConfiguration": true,
"commands": [
{
"id": "getRandomText",
"type": "query",
"title": "Get some random text for fun",
"description": "Gets some random text and images",
"initialRun": true,
"fetchTask": false,
"context": [
"commandBox",
"compose",
"message"
],
"parameters": [
{
"name": "cardTitle",
"title": "Card title",
"description": "Card title to use",
"inputType": "text"
}
]
}
]
}
],
"permissions": [
"identity",
"messageTeamMembers"
],
"validDomains": [
"echobot57.azurewebsites.net"
]
}
Please make sure the tab configuration url is correct.
If it is correct, you should be able to access it.
https://microsoftteamssampleshelloworldweb20200107021253.azurewebsites.net/configure
I'm trying to create an Azure container instance and mounting a File Storage volume via REST API, but I'm getting 400 response.
I'm able to create the container and keep it running but when I add the volume part it returns a 400 response (Bad request) without further explanation
Here is the JSON payload I'm sending to the REST endpoint:
{
"id": "/subscriptions/111111111/resourceGroups/OraResourceGroup/providers/Microsoft.ContainerInstance/containerGroups/solver",
"location": "West Europe",
"name": "solver",
"properties": {
"volumes": [
{
"azureFile": {
"shareName": "orafileshare",
"storageAccountKey": "somekey",
"storageAccountName": "myaccountname"
},
"name": "Volume1"
}
],
"containers": [
{
"name": "solver",
"properties": {
"command": [],
"environmentVariables": [],
"image": "acraccount/solver:v1",
"ports": [
{
"port": 12345
}
],
"resources": {
"requests": {
"cpu": 1.0,
"memoryInGB": 1.5
}
},
"volumeMounts": [
{
"name": "Volume1",
"mountPath": "/mountFolder"
}
]
}
}
],
"imageRegistryCredentials": [
{
"password": "123123123213123",
"server": "acr.server.io",
"username": "acrOra"
}
],
"ipAddress": {
"ports": [
{
"protocol": "TCP",
"port": 12345
}
],
"type": "Public"
},
"osType": "Linux",
"restartPolicy": "Always"
},
"type": "Microsoft.ContainerInstance/containerGroups"
}
The expected results is a 200 or 201 response and the container should appear on my Azure portal dashboard but the actual response is 400.
There are 2 issues with this correction. I also received 400 bad request but later corrected it and I was able to run it successfully.
Name of volume, capital letter is not allowed.
Change "Volume1" to "volume1"
Reference Error :
{"error":{"code":"InvalidVolumeName","message":"The volume name 'Volume1' is invalid. The volume name must match the regex '[a-z0-9]([-a-z0-9]*[a-z0-9])?' (e.g. 'my-name')."}}
Sku is not a valid property, Remove it
{"error":{"code":"InvalidRequestContent","message":"The request
content was invalid and could not be deserialized: 'Could not find
member 'sku' on object of type 'ComputeResources'. Path
'properties.containers[0].properties.resources.requests.sku', line 32,
position 22.'."}}
Reference https://learn.microsoft.com/en-us/rest/api/container-instances/containergroups/createorupdate#resourcerequests
Sample configuration
{
"id": "/subscriptions/xxxx/resourceGroups/teststoragerest/providers/Microsoft.ContainerInstance/containerGroups/solver",
"location": "West Europe",
"name": "demo1forrahul",
"properties": {
"volumes": [
{
"azureFile": {
"shareName": "testfilestorage",
"storageAccountKey": "xxxx",
"storageAccountName": "xxxxxx"
},
"name": "volume1"
}
],
"containers": [
{
"name": "demo1forrahul",
"properties": {
"command": [],
"environmentVariables": [],
"image": "nginx",
"ports": [
{
"port": 80
}
],
"resources": {
"requests": {
"cpu": 1.0,
"memoryInGB": 1.5
}
},
"volumeMounts": [
{
"name": "volume1",
"mountPath": "/testfolder"
}
]
}
}
],
"imageRegistryCredentials": [],
"ipAddress": {
"ports": [
{
"protocol": "TCP",
"port": 80
}
],
"type": "Public"
},
"osType": "Linux",
"restartPolicy": "Always"
},
"type": "Microsoft.ContainerInstance/containerGroups"
}