I'm having a weird issue when deploying resources using Bicep that I'm hoping someone can share some light on.
For several resources I am deploying, I am trying to deploy with the non-preview versions of the API, for example:
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces#2022-10-01' = {
name: name
location: location
properties: {
sku: {
name: sku
}
retentionInDays: logAnalyticsRetentionInDays
}
tags: tags
}
When I deploy this, it deploys succesfully, however when I check in the portal,the Log Analytics workspace has defaulted to "apiVersion": "2021-12-01-preview".
This is occurring for a few different resources such as API Management as well. Can anyone give any insight on why this occurs and if there's a way to not have it occur?
Thanks,
Any insight on why this occurs and if there's a way to not have it occur.
Preview versions are similar to updated versions released by the team prior to gathering feedback or verifying the functionality.
Version will be automatically set to the latest/preview version after deployment, depending on the properties/fields provided in the bicep resource type.
A few Azure Services may no longer support non-preview versions when deployed using bicep. Use Azure CLI in that case.
In the Json/parameters file, every resource type includes a version parameter. If required, provide the required version.
Note: I would suggest you not to use non preview versions as some of them doesn't have the updated fields & functionality.
Refer MSDoc: 1 & 2
Related
I am new to using Azure bicep. I am trying to deploy a simple app service plan/app service with the following bicep file:
resource azBicepAsp1 'Microsoft.Web/serverfarms#2020-12-01' = {
name: 'test-dev-aue-asp1'
location: resourceGroup().location
kind: ''
sku: {
name: 'F1'
capacity: 1
}
}
resource azbicepas 'Microsoft.Web/sites#2021-01-15' = {
name: 'test-dev-aue-wapp1'
location: resourceGroup().location
properties: {
serverFarmId: resourceId('Microsoft.Web/serverfarms', 'test-dev-aue-asp1')
}
dependsOn:[
azBicepAsp1
]
}
using:
az deployment group create -g azbbicepad-dev-au-rg1 -f 2.AppServicePlan.bicep --confirm-with-what-if
It deploys sucesfully, however if I deploy it again with the exact same deployment it says the following changes will be made:
- Delete
+ Create
~ Modify
The deployment will update the following scope:
Scope: /subscriptions/71913b63-cacf-41bf-9da1-e3a1db24e62c/resourceGroups/azbbicepad-dev-au-rg1
~ Microsoft.Web/serverfarms/test-dev-aue-asp1 [2020-12-01]
- kind: "app"
~ sku.capacity: 0 => 1
~ Microsoft.Web/sites/test-dev-aue-wapp1 [2021-01-15]
+ properties.siteConfig.localMySqlEnabled: false
+ properties.siteConfig.netFrameworkVersion: "v4.6"
I don't quite understand why this occurs - could someone please point me in the right direction?
Thanks,
Regarding the app service plan:
if you specify Free tier, the capacity is always 0. When you deploy your template the first time, the capacity specified is ignored and set to 0. When you redeploy, there is a mismatch between what's defined in the template and the target resource.
If you dont specify the kind, the default is app. Same here, there is a mismatch between the template and the target resource.
There is a good explanation on this post.:
Noise
One issue you may see when using this command is noise, where the results show that a resource is being changed when no change will occur. This is usually down to the fact that the information you provide to the ARM API to create or update a resource is less than the data returned when querying it, or that defaults are being used. An example seen early in the preview was when deploying a storage account, if you did not specify the encryption settings in the template (so using the defaults), then What-If showed a change because it thought it was removing these settings.
This is something the ARM team is aware of and are working to remove during the preview. They are asking for everyone using this command to keep an eye out for these issues and log them in this Github issues log. Please do log issues when you see them to help improve this command and get it out of preview as soon as possible.
With Azure Devops Services, I need to get azure devops user id which triggered a release, from task.json.
I've got a datasourcebinding with Azure API Management service. This has to get Azure API Management tag based on user id. I've tried different approach :
{
"target": "TEST",
"endpointId": "$(ConnectedServiceName)",
"endpointUrl": "{{endpoint.url}}/subscriptions/{{endpoint.subscriptionId}}/resourceGroups/$(ResourceGroupName)/providers/Microsoft.ApiManagement/service/$(APIM)/products?tags=**$(Release.RequestedForId)**&api-version=2019-12-01",
"resultSelector": "jsonpath:$.value[*]",
"resultTemplate": "{\"Value\" : \"{{{id}}}\", \"DisplayValue\" : \"{{{properties.displayName}}}\" }"
},
I tried also with {{Release.RequestedForId}} but it didn't work.
I saw different resources for datasourcebinding support :
tfs:teamfoundation – Any micro service hosted within TFS (e.g. Build, Test etc.)
tfs:packaging – Packaging service
tfs:feed – Feed service
tfs:rm – Release Management service
tfs:governance - Governance service
tfs:ems - Extension Management service
I found examples for tfs:feed and tfs:teamfoundation only.
Is there any section for users ? Is there any additional information apart from Azure Devops Services REST API ?
Quite few examples in but none for user request.
Is it possible to get current context release variables or azure devops user id directly in task.json ?
This would be a huge help.
Thank you !
You made a small misatke. Instead of Release.RequestedForId please give a try for Release.Deployment.RequestedFor of Release.Deployment.RequestedForId
Docs for Release.Deployment.RequestedFor says:
The display name of the identity that triggered (started) the
deployment currently in progress. Not available in TFS 2015.
Example: Mateo Escobedo
Docs for Release.Deployment.RequestedForId says:
The ID of the identity that triggered (started) the deployment
currently in progress. Not available in TFS 2015.
Example: 2f435d07-769f-4e46-849d-10d1ab9ba6ab
You have this written here.
Does anyone know if it is possible to specify the Kubernetes version when deploying ACS Kubernetes flavour?
If so how?
Using the supported resource provider in ARM you cannot specify the version. However, if you use http://github.com/Azure/acs-engine you can do so. ACS Engine is the open source code we (I work for MS) use to drive Azure Container Service. Using this code you have much more flexibility than you do through the published resource provider, but it's a harder onramp. For instructions see https://github.com/Azure/acs-engine/blob/master/docs/kubernetes.md
See examples at https://github.com/Azure/acs-engine/tree/master/examples/kubernetes-releases
You should use acs-engine and follow the deploy guide in the repo (https://github.com/Azure/acs-engine/blob/master/docs/kubernetes/deploy.md).
In the deploy guide they use the file examples/kubernetes.json and in that file there's -
"orchestratorProfile": {
"orchestratorType": "Kubernetes"
}
You can also add the field "orchestratorRelease": "1.7" for Kubernetes 1.7.
To view the whole list of releases available you can use the acs-engine executable and run acs-engine orchestrators that prints all of them.
Other examples can be found in https://github.com/Azure/acs-engine/tree/master/examples/kubernetes-releases
I'm trying to build a small program to change the autoscale settings for our Azure WebApps, using the Microsoft.WindowsAzure.Management.Monitoring and Microsoft.WindowsAzure.Management.WebSites NuGet packages.
I have been roughly following the guide here.
However, we are interested in scaling WebApps / App Services rather than Cloud Services, so I am trying to use the same code to read the autoscale settings but providing a resource ID for our WebApp. I have already got the credentials required for making a connection (using a browser window popup for Active Directory authentication, but I understand we can use X.509 management certificates for non-interactive programs).
This is the request I'm trying to make. Credentials already established, and an exception is thrown earlier if they're not valid.
AutoscaleClient autoscaleClient = new AutoscaleClient(credentials);
var resourceId = AutoscaleResourceIdBuilder.BuildWebSiteResourceId(webspaceName: WebSpaceNames.NorthEuropeWebSpace, serverFarmName: "Default2");
AutoscaleSettingGetResponse get = autoscaleClient.Settings.Get(resourceId); // exception here
The WebApp (let's call it "MyWebApp") is part of an App Service Plan called "Default2" (Standard: 1 small), in a Resource Group called "WebDevResources", in the North Europe region. I expect that my problem is that I am using the wrong names to build the resourceId in the code - the naming conventions in the library don't map well onto what I can see in the Azure Portal.
I'm assuming that BuildWebSiteResourceId is the correct method to call, see MSDN documentation here.
However the two parameters it takes are webspaceName and serverFarmName, neither of which match anything in the Azure portal (or Google). I found another example which seemed to be using the WebApp's geo region for webSpaceName, so I've used the predefined value for North Europe where our app is hosted.
While trying to find the correct value for serverFarmName in the Azure Portal, I found the Resource ID for the App Service Plan, which looks like this:
/subscriptions/{subscription-guid}/resourceGroups/WebDevResources/providers/Microsoft.Web/serverfarms/Default2
That resource ID isn't valid for the call I'm trying to make, but it does support the idea that a 'serverfarm' is the same as an App Service Plan.
When I run the code, regardless of whether the resourceId parameters seem to be correct or garbage, I get this error response:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
{"Code":"SettingNotFound","Message":"Could not find the autoscale settings."}
</string>
So, how can I construct the correct resource ID for my WebApp or App Service Plan? Or alternatively, is there a different tree I should be barking up to programatially manage WebApp scaling?
Update:
The solution below got the info I wanted. I also found the Azure resource explorer at resources.azure.com extremely useful to browse existing resources and find the correct names. For example, the name for my autoscale settings is actually "Default2-WebDevResources", i.e. "{AppServicePlan}-{ResourceGroup}" which I wouldn't have expected.
There is a preview service https://resources.azure.com/ where you can inspect all your resources easily. If you search for autoscale in the UI you will easily find the settings for your resource. It will also show you how to call the relevant REST Api endpoint to read or update that resorce.
It's a great tool for revealing a lot of details for your deployed resources and it will actually give you an ARM template stub for the resource you are looking at.
And to answer your question, you could programmatically call the REST API from a client with updated settings for autoscale. The REST API is one way of doing this, the SDK another and PowerShell a third.
The guide which you're following is based on the Azure Service Management model, aka Classic mode, which is deprecated and only exists mainly for backward compatibility support.
You should use the latest
Microsoft.Azure.Insights nuget package for getting the autoscale settings.
Sample code using the nuget above is as below:
using Microsoft.Azure.Management.Insights;
using Microsoft.Rest;
//... Get necessary values for the required parameters
var client = new InsightsManagementClient(new TokenCredentials(token));
client.AutoscaleSettings.Get(resourceGroupName, autoScaleSettingName);
Besides, the autoscalesettings is a resource under the "Microsoft.Insights" provider and not under the "Microsoft.Web" provider, which explains why you are not able to find it with your serverfarm resourceId.
See the REST API Reference below for getting the autoscale settings.
GET
https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/microsoft.insights/autoscaleSettings/{autoscale-setting-name}?api-version={api-version}
I am trying to use Azure resource manager and Azure Compute Management APIs to get list of virtual machines in a resource group and all of virtual machine properties. It's failing with InvalidAPIVersion error even though I have updated to latest version. As per the error it expects older version no but i don't see any old library with such a version. Can someone please suggest what am I missing?
VirtualMachineGetResponse vm = m_computeClient.VirtualMachines.Get("/subscriptions/1f94c869-####-####-####-055e8ae15be3/resourceGroups/TestGroup", "TestMachine");
m_computeClint is an object of ComputeManagementClient class in name space Microsoft.Azure.Management.Compute
Is this because resource provider is Microsoft.ClassicCompute?
Error message:
InvalidApiVersionParameter: The api-version '2015-05-01-preview' is invalid. The supported versions are '2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'.
If you're using the resource group management api, you're definitely going to get an invalidapiversionparameter using ClassicCompute. The resource management compute provider is "Microsoft.Compute"; ClassicCompute exists only to view VMs that were already created using the service management API.
Right now, you should keep the two APIs and resources separate. Did you create the VM using the preview portal (portal.azure.com) or using PowerShell? If the former, it has almost (but not quite) converted over to using the resource management api. Try following these steps: https://azure.microsoft.com/en-us/documentation/articles/resource-group-template-deploy/.
Hope that helps.